When will the complex types be dumped?
Lars T. Kyllingstad
public at kyllingen.NOSPAMnet
Tue Dec 8 00:14:29 PST 2009
Andrei Alexandrescu wrote:
> Lars T. Kyllingstad wrote:
>> The decision to dump the built-in complex and imaginary types in
>> favour of std.complex.Complex was made a long time ago, but nothing
>> has happened yet. So I have a few questions:
>>
>> 1. Is this still planned for D2?
>
> Far as I know, yes.
>
>> 2. In that case, when will it happen?
>
> I don't know.
>
>> 3. Are there any reasons why I shouldn't replace cxxx with Complex!xxx
>> in my code right away?
>
> I think we'll have to provide aliases for the existing complex types, so
> your code should continue functioning after the change.
The big difference is in assignments:
real a, b;
creal x = a + b*1.0i;
auto y = Complex!real(a, b);
// Also, this doesn't work with current complex types, because
// creal.re and creal.im aren't lvalues:
Complex!real z;
z.re = a;
z.im = b;
But it's not a problem, really. Since Complex!T is binary compatible
with the current complex types I can just insert a few casts here and
there. I just wanted to make sure I wouldn't have to go back to creal &
co later.
-Lars
More information about the Digitalmars-d
mailing list