Article about problems & suggestions for D 2.0
David Nadlinger
see at klickverbot.at
Sun Aug 28 12:44:51 PDT 2011
On 8/28/11 8:54 PM, Alex Rønne Petersen wrote:
> const_cast is the root of all evil. I really don't want to see it in D.
>
> - Alex
It is already in D, and in an, in my personal opinion, much worse way:
You can just cast away const/immutable with cast().
What do you propose for the situations where you need to cast away
const? (Yes you'll find yourself in one of them from time to time in the
real world, e.g. when dealing with legacy/C code…)
I know that this is not the general consensus, but I very much like the
C++ casting operators, because you can quickly get a rough idea what is
going on when you see a cast in the code, whereas for D, cast() be
anything between a perfectly harmless downcast (if checking for null,
obviously), changing the storage class (const/immutable/shared), or
causing the bytes stored to be interpreted in a completely different way!
David
More information about the Digitalmars-d
mailing list