Why is complex being deprecated again?

Lars T. Kyllingstad public at kyllingen.net
Mon Apr 16 04:42:18 PDT 2012


On Monday, 16 April 2012 at 11:27:29 UTC, Stewart Gordon wrote:
> On 16/04/2012 07:06, Lars T. Kyllingstad wrote:
> <snip>
>> For any standard type (built-in or library) to be useful, it 
>> has to actually be used for
>> something.
>
> You mean someone has to use it in order to prove that it's 
> usable and therefore useful? Well, if a feature isn't usable, 
> it's probably due to something wrong with its design. And in 
> many cases it's a reason to rethink the design, rather than 
> throw the feature out of the window.
>
>> And in all my years of using D, I have never seen a *single* 
>> real-world use of
>> the pure imaginary types.
>
> How many of those years you spent "using" D did you spend 
> looking at other people's real-world applications written in it?
>
> Of these, how many have a focus on number crunching?
>
> And of these, how many use complex numbers?

This is why I said: "[...] if anyone can demonstrate that the 
pure imaginary types are in fact used in a substantial body of 
real-world code, I will be happy to change my stance [...]"


> It's bound to be a rarely used feature.  But "nobody's using 
> it" is a prime example of a self-fulfilling prophecy if it 
> leads to the feature's removal.

I'm not saying it is *never* useful.  I'm saying I don't think 
it's useful *enough* to warrant inclusion in the standard library.


> Do you feel the SETI Institute should have given up years ago?

I don't really see the similarity between SETI and Phobos.


>> The reason the imaginaries are so seldomly used is precisely 
>> because there are so few
>> things you can do with them. Basically, if you do anything 
>> beyond addition and
>> subtraction, and multiplication with a real number, you are 
>> back in the complex plane. And
>> if those operations are all you need, the real line is just as 
>> good as the imaginary line,
>> and you might as well fake it with a real floating-point type.
>
> This doesn't cover the case of multiplying a complex number by 
> an imaginary number.  In the absence of imaginary types, one 
> would have to use complex(-z.im * k, z.re * k), just because z 
> * complex(0, k) isn't guaranteed to produce the correct result.
>  Seems a bit silly.  Or have you another suggestion for dealing 
> with this?

Yes:  Define Complex!T so it produces the desired result in each 
case.


> <snip>
>> It is true that the real line can be extended with elements 
>> called plus and minus infinity
>> (affinely extended real line, see 
>> https://en.wikipedia.org/wiki/Extended_real_number), and
>> the IEEE floats can be said to approximate this system, but 
>> this does not generalise
>> directly to complex numbers. The extended complex plane (see
>> https://en.wikipedia.org/wiki/Riemann_sphere) only has one 
>> "infinity".
> <snip>
>
> But the Riemann sphere is only one of the various possible 
> extended complex planes.  You could just as well use the polar 
> circle of infinities, the cartesian square of infinities, or 
> the real projective plane model (by which -∞ = ∞, but ∞i, 
> ∞(2+i), etc. are distinct).

My point exactly.

-Lars


More information about the Digitalmars-d mailing list