Remove complex and imaginary types?

Bruce Adams tortoise_74 at yeah.who.co.uk
Mon Jan 7 14:46:53 PST 2008


On Mon, 07 Jan 2008 08:35:20 -0000, Bill Baxter  
<dnewsgroup at billbaxter.com> wrote:

> 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.
>
You must surely have noticed people using all kinds of weird and wonderful  
excuses
as justifications for their pet new syntax feature proposal. I think  
complex numbers
like any other feature have to stand or not on their own.

> 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

My own feeling is if it ain't broke don't fix it. Walter must have  
something up his
sleeve if he's thinking of changing it. It could just be cosmetic. Its  
common in a new
language for features to be hard coded and gradually replaced with  
libraries as the
language becomes strong enough to support better modularity. I can't think  
of any other
language where complex numbers are built in rather than a library (only  
because I've
never looked mind). However, I can't think of any language that has a rich  
enough syntax
to let you write 3+5i like that. Though I can see it happening in a duck  
typed language.

Bruce.



More information about the Digitalmars-d mailing list