Safer casts
terranium
spam at here.lot
Fri May 9 02:48:15 PDT 2008
Janice Caron Wrote:
> to!(T)(x) // convert
> is!(T)(x) // is upcast or downcast possible?
> class!(T)(x) // upcast or downcast
> union!(T)(x) // reinterpret the bits
> auto!(T)(x) // remove constancy
> invariant!(T)(x) // add invariance
1) I don't think you can throw away the cast keyword, this will break all existing code.
2) how about interfaces?
3) I believe reinterpret_cast was introduced as analog of C cast, D already has cast for this purpose. I don't think D needs union!().
4) D already has cast to add/remove constancy/invariance.
My proposal was just adding safe cast for downcasts with the syntax of existing cast, nothing more.
More information about the Digitalmars-d
mailing list