D2.0: an example of use-case for casting invariant away

Daniel Keep daniel.keep.lists at gmail.com
Sat Jun 23 23:54:43 PDT 2007


"Damnit; I don't understand what's going wrong here."

"It looks like you're modifying const data.  Did you cast const away
anywhere?"

"I use unConst, and I already checked all the lines that use that, and
they're fine!"

"But what if you *forgot* to use unConst?"

"... Uh-oh."

The problem with your suggestions is that unless either A) it's
compiler-enforced or B) humans suddenly become infallible, it's really
not solving the problem at all.  If someone forgets to use unConst, or
worse, casts away const *without realising it*, they're screwed.

And I *really* doubt B is going to happen.

	-- Daniel



More information about the Digitalmars-d mailing list