Remove complex and imaginary types?

Bill Baxter dnewsgroup at billbaxter.com
Mon Jan 7 00:35:20 PST 2008


Walter Bright wrote:
> The issue comes up now and then about why have complex and imaginary 
> types, rather than using structs? All but one of the advantages of 
> having them be core types can be addressed with advancing compiler 
> technology. Getting rid of them will release 6 keywords, and make the 
> core language simpler. Given the increasing complexity of D, this will 
> help.
> 
> The remaining advantage is that of imaginary literals, i.e. the i postfix:
> 
>     3 + 5i
> 
> Assuming we solve the literal problem, existing code would only need to 
> add:
> 
>     import std.complex;
> 
> to acquire complex and imaginary types.

I defer to Don on this one :-)

But I will say I seem to have heard arguments like this pretty often: 
"Well complex numbers are built-in, and my <new confoobulator> will be 
used at least as much as complex numbers."  So that seems a little 
telling to me.

I personally haven't had much need for complex numbers, but I maintain 
wrappers for a number of Fortran math libraries which have APIs for 
cfloat and cdouble.  My main fear is just that going from built-in to 
not means I'll need to maintain different versions of these for D1.0, 
D2.0, and maybe D2.0/Tango when that comes out.  Right now I think 
they're pretty much version independent.

--bb



More information about the Digitalmars-d mailing list