Safer casts

Janice Caron caron800 at googlemail.com
Fri May 9 10:32:47 PDT 2008


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.



More information about the Digitalmars-d mailing list