Safer casts

BCS BCS at pathlink.com
Fri May 9 14:11:36 PDT 2008


Janice Caron wrote:
> On 09/05/2008, Janice Caron <caron800 at googlemail.com> wrote:
> 
>> >  I'd rather see a testClass!(T) version that acts exactly like the current
>> > cast and a isClass!(T) that acts like your class!(T).
>>
>>OK, so how about just making class!(T) return null, and do away with
>> is!(T)? That's what C++ does with dynamic_cast<T>, after all.
> 
> 
> One goal of the proposal was to avoid introducing more keywords. Some
> of these conversions don't have to be keywords, of course. to! is
> already implemented in std.conv, and this proposal only suggests
> extending its reach. But others kinds of transformation are better
> done by the compiler, and I'd say that includes RTTI, so for that
> reason, I went for keyword reuse.

I think it you go with the __!(T) syntax it would be better to /not/ 
used keywords at all. Make them either "magic" template that are defined 
in the compiler or as part of the compiler specific runtime.



More information about the Digitalmars-d mailing list