www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - couldn't we keep complex number literals?

reply Trass3r <un known.com> writes:
I'm not completely sure how AAs are implemented now, but I think I read  
it's somewhat outsourced to druntime. At least there's that struct  
AssociativeArray(Key, Value) there.

Couldn't we do something similar with complex numbers?
Like moving the struct Complex(T) implementation that currently resides in  
std.complex to the runtime, removing the types (creal etc.), adding them  
as aliases there and providing some slight syntactic sugar so that complex  
number literals 5 + 3i are mapped onto a Complex instance?

I think that would be an ideal solution, wouldn't it?
Jul 26 2010
next sibling parent bearophile <bearophileHUGS lycos.com> writes:
Trass3r:
 Couldn't we do something similar with complex numbers?
I have proposed this idea lot of time ago (and I was not the only one), but I don't know what Walter thinks about it. I think he thinks that complex literals are not so important in D (despite D is a designed for numerical computing too). I suggested a similar solution for multi-precision integers too: bint i = 1_234_567_890_123_456_789_012_345_678_901_234_567_890; Bye, bearophile
Jul 26 2010
prev sibling parent Don <nospam nospam.com> writes:
Trass3r wrote:
 I'm not completely sure how AAs are implemented now, but I think I read 
 it's somewhat outsourced to druntime. At least there's that struct 
 AssociativeArray(Key, Value) there.
 
 Couldn't we do something similar with complex numbers?
 Like moving the struct Complex(T) implementation that currently resides 
 in std.complex to the runtime, removing the types (creal etc.), adding 
 them as aliases there and providing some slight syntactic sugar so that 
 complex number literals 5 + 3i are mapped onto a Complex instance?
 
 I think that would be an ideal solution, wouldn't it?
I believe that is the plan.
Jul 26 2010