Replacing built-in complex? What's this about?
Don
nospam at nospam.com
Sun Dec 28 08:34:51 PST 2008
Stewart Gordon wrote:
> The plan to remove the built-in complex and imaginary types has finally
> come to my attention. I seem to have somehow blinked and missed the
> discussions earlier this year about it.
>
> The motives seem to be along the lines of reducing compiler complexity
> (not sure if any pun has been intended) and freeing up keywords. But is
> it really worth it?
The argument for built-in imaginary types is _extremely_ weak. The
imaginary numbers are not closed under multiplication:
idouble a, b;
auto c = a * b;
c is of type double! This is a horribly nasty thing to have in the core
language. It introduces so many special cases, and for almost no benefit
at all. You never want to use imaginary numbers, you _always_ want to
convert them to reals. The only thing you want, really, is the imaginary
literal 1i. The ireal, idouble, and ifloat types with their bizarre
semantics are a hell of a price to pay for that one literal.
More information about the Digitalmars-d
mailing list