Accidentally killing immutable is too easy in D (Was: cast()x - a
Jonathan M Davis
jmdavisProg at gmx.com
Fri Jun 3 10:41:59 PDT 2011
On 2011-06-03 05:14, bearophile wrote:
> 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.
And I would argue that the fact that you have separate casts in the first
place is 90% of the problem. Sure, you could design the casts better, but
having to deal with more than one type of cast is the core of my complaint in
the first place. I find it to be very annoying and of little value.
- Jonathan M Davis
More information about the Digitalmars-d
mailing list