## digitalmars.D - Re: Remove complex and imaginary types?

```Bill Baxter:
but for a programming language it's bad practice to
have a lot of magic literals in your code anyway.  I.e.

creal rot45 = creal(.707, 707);
creal xr = rot45 * x;

is better than
creal xr = (.707 + 0.707i) * x;

in my opinion.  As long as complex constants can still be put in static
arrays, it should be ok.

Python has the literals too:

complex(5)

(6 + 2j - 1 + 3j) / 3j

(complex(6, 2) - complex(1, 3)) / complex(0,3)

But maybe imaginary literals aren't necessary:

C++
complex<long double> a = 5;
complex<long double> b(0,7);
c = a + b + complex<long double>(0,7);

Current D:
creal a = 5;
ireal b = 7i;
c = a + b + 7i;

Alternative:
auto a = creal(5); // == creal(5,0)
auto b = ireal(7);
c = a + b + ireal(7);

C++:
c = (complex<double>(6,2) + complex<double>(-1,3)) / complex<double>(0,3);

Current D:
c = (6 + 2i - 1 + 3i) / 3i;

Alternative:
c = (creal(6,2) + cdouble(-1,3)) / idouble(3);

Bye,
bearophile
```
Jan 07 2008