The cast(signed), cast(unsigned) feature proposal

Marco Leise Marco.Leise at gmx.de
Fri Jun 7 23:47:30 PDT 2013


Am Fri, 07 Jun 2013 17:03:47 -0400
schrieb Andrei Alexandrescu <SeeWebsiteForEmail at erdani.org>:

> On 6/7/13 4:52 PM, Mrzlga wrote:
> > Hi guys,
> >
> > This is a small feature proposal.
> > Please consider to add these to the language:
> >
> > cast(signed)
> > cast(unsigned)
> 
> http://dlang.org/phobos/std_traits.html#.unsigned
> 
> We should prolly add signed() as well. Could you please author an 
> enhancement request (and at best a pull request too)?
> 
> 
> Thanks,
> 
> Andrei

That made me scratch my head again. I thought
std.traits contains non-modifying queries into the type system
and std.typecons contains the _actions_ for type system
trickery.
In any case I wouldn't have searched std.traits for a function
that gets stuff done.

On the topic, I think that D's cast() does too many things in
one. You can _accidentally_ cast away immutable for example
and run into undefined behavior as per the language specs. At
first I liked how D got rid of C's different casts, but on the
long run it is too pragmatic for my taste.

-- 
Marco



More information about the Digitalmars-d mailing list