Jonathan M Davis:

> Personally, I find 
> how C++ created multiple types of cast (include const_cast) _highly_ annoying 
> and generally useless, and I'm _very_ glad that D didn't do anything of the 
> sort.

Conflating all casts in a single syntax makes the D language look a bit 
simpler, but it also reduces the amount of expressivity and I suspect it may 
lead to some bugs (here Unqual helps). Changing the const state of a type is 
often orthogonal to changing its data type.

Thankfully D templates make it easy enough to build new types of cast. Time ago 
I have proposed a staticObjCast! for object references that performs some 
static sanity tests too. Unqual!() is another kind of cast, but it's a bit 
blunt. std.conv.to! is another kind of cast, that performs more complex 
conversions too. I am proposing to use to! for safe enum conversions too. A 
staticCast! that uses a locally defined enum sounds useful and safe.

Bye,
bearophile

Reply via email to