Accidentally killing immutable is too easy in D (Was: cast()x - a

bearophile bearophileHUGS at lycos.com
Fri Jun 3 05:14:48 PDT 2011


Jonathan M Davis:

> Personally, I find the added complexity of C++'s special casts to _far_ 
> outweight what benefit they give you.

I don't want to copy C++, I prefer casts better designed than C++ ones, and probably they don't need language-level support. I'd like a cast to cast enums safely, to be integrated into to!(). A StaticObjCast just for statically and safely cast object references. One cast to change the const status of a type const <-> immutable <-> mutable. I'd like to keep unqual and to!(). dynCast is better explicit, because it has a not small runtime cost, and its purpose is quite different from other casts, so such differences are worth showing visually too.

Bye,
bearophile


More information about the Digitalmars-d mailing list