Remove complex and imaginary types?

BCS ao at pathlink.com
Tue Jan 8 12:19:40 PST 2008


Reply to Don,

> 
> 100% of the benefits of ireal could be obtained by including a
> guaranteed optimisation that
> 
> complexA * realR * complex_literalB
> 
> becomes simply complex(-A.im*R*B.im, A.re*R*B.im)
> when the literal B has a real part of zero.
> (and similarly for division).


This is starting to touch on something I have been wanting: compile time 
access to literals. In my backmath lib you can't use literal values:

A + B = C * 3; // fails 3 is of wrong type

One thing that would fix this quite well would be to allow a "constant cast" 
where constant is really constant.

with this:

Value!(v) implicitCast(real v)(){return Value!(v).init}

the above processes as:

A + B = C * implicitCast!(3)();

Having access to literal values at the typing stage would allow all kinds 
of cool stuff at compile time.





More information about the Digitalmars-d mailing list