Created
August 3, 2009 19:03
-
-
Save ujihisa/160767 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SUBJECT: About An Imaginary Number Literal (Translation) | |
This post is the summary of a recent discussion in [ruby-dev] about inaginary numbers. | |
In [ruby-dev:38843] 複素数リテラルについて http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-dev/38843 , | |
Matz suggested to introduce an inaginary number literal ruby. After his new patch is applied, we can use the following syntax. | |
2i | |
2.0i | |
He also showed some issues. | |
* Backward compatibility | |
* Is i OK? (In python it's j) | |
* Is Numeric#i needed for imaginarization? | |
* If it is needed, what's the value of (an imaginary number).i or (a complex number).i ? | |
The discussions about the topic are outlines below. | |
* Numeric#i should be equivalent to Complex(0, self) | |
* i is better for it's more popular than j | |
* It is confusing to introduce both i and j because of quatenion's i, j and k | |
* Numeric#i should be one of them: (1) 2.0i == 2.0.i (2) returns the imaginary part (3) represents as a complex number like 2.0.i #=> 2.0 + 0i; (1) is the best | |
* Is Numeric#i really needed? We can write s.i as s * 1i | |
* The fact 1/3i in Ruby becomes (-1/3)i in Mathematics is confusing | |
* Actually once Numeric#i was proposed and reject on 1.9.1 | |
* Is the literal really needed? What's the use case? Is it enough general? | |
* How about an "imaginariztion syntax" like 1+(2)i, 1+(n)i or 1+3#i | |
* Good literals matter | |
* Only in IRC is better or worse | |
* How about introducing Math::I (1 + n * Math::I) | |
* Complex::I is already exist | |
* Programming language J describes 1+3i as 1j3 | |
* Matz supposes there must be someone who use complex numbers often | |
* Matz supposes this topic was for 2.0, but may make in on 1.9.2 | |
* 1+2i is too dissimilar to Complex(1, n). "1+(2)i and 1+(n)i" is better. | |
* "1+2i and 1+n.i" is better | |
* "1+2.i and 1+n.i" is better for less rules | |
* How about introducing this syntax sugar: 2xxx is equivalent to 2 * Math::XXX | |
* Imaginary numbers and Complex numbers are fundamentally different, so 1+2i should be Complex(1, 2) rather than 1.+(Complex(0, 2)) | |
* see also: C++0x current draft has User-defined literals | |
* How about 2i #=> 2.literal_i, 3/2r #=> 3 / 2.literal_r, 5C3 #=> 5.literal_C(3) | |
* It is useful to apply it within a classbox | |
Although this discussion isn't shaping up, now there has been no new posts since 11 days ago. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment