www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - When will the complex types be dumped?

reply "Lars T. Kyllingstad" <public kyllingen.NOSPAMnet> writes:
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?

2. In that case, when will it happen?

3. Are there any reasons why I shouldn't replace cxxx with Complex!xxx 
in my code right away?

-Lars
Dec 07 2009
next sibling parent KennyTM~ <kennytm gmail.com> writes:
On Dec 7, 09 22:40, 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?

 2. In that case, when will it happen?

 3. Are there any reasons why I shouldn't replace cxxx with Complex!xxx
 in my code right away?
All opBinary-s (opAdd, etc.) aren't implemented now, so e.g. z+w won't compile for Complex!T.
 -Lars
Dec 07 2009
prev sibling next sibling parent Ali Cehreli <acehreli yahoo.com> writes:
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?
 
 2. In that case, when will it happen?
 
 3. Are there any reasons why I shouldn't replace cxxx with Complex!xxx 
 in my code right away?
 
 -Lars
An introductory article on Digital Mars explains the rationale behind the complex types and quotes W. Kahan: "The language of pairs is incorrect for Complex Arithmetic; it needs the Imaginary type." http://www.digitalmars.com/d/2.0/cppcomplex.html The library types can and do work as well, probably because "Appendix G of the C99 standard has recommendations for dealing with this problem." Ali
Dec 07 2009
prev sibling parent reply Andrei Alexandrescu <SeeWebsiteForEmail erdani.org> writes:
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. Andrei
Dec 07 2009
parent "Lars T. Kyllingstad" <public kyllingen.NOSPAMnet> writes:
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
Dec 08 2009