Fixing the imaginary/complex mess

Robert Fraser fraserofthenight at gmail.com
Thu Apr 30 15:41:07 PDT 2009


bearophile wrote:
> Robert Fraser:
>> Ehhh.... why not leave complex and just kill imaginary? That'd solve 
>> most of the problems.
> 
> You can't remove only half of a feature of the language, so I don't like this idea.
> I accept to remove them fully if their semantics can be fully replaced by the std lib. Otherwise just let Don fix the broken things.
> 
> Bye,
> bearophile

It's not necessarily "removing half a feature". Imaginary numbers aren't 
closed under many operations. The idea is that imaginary literals are 
turned into complex. So "ireal x = 10i;" becomes "creal x = 0 + 10i;". 
Since complex numbers are closed under all the builtin operators, it 
eliminates many of the problems (casts from complex to real).

Putting it in a library eliminates the ability to use complex/imaginary 
literals (unless it's a runtime type).



More information about the Digitalmars-d mailing list