cast(!const) proposal

Lutger lutger.blijdestijn at gmail.com
Sun Sep 9 09:11:15 PDT 2007


I think this is good idea. It will help to find this class of bugs, 
which although one shouldn't make, if it is there it will be sneaky one.

Note that if you want to cast the underlying types too it will be quite 
ugly:

auto q = cast(long*)cast(!const)p;

You might agree that the syntax of !const can be something different, it 
doesn't really matter as long as it achieves the same thing: catching 
casting away const by accident. I personally don't care if it's 
foobar_cast or whatever, if it's recognizable that's fine.

It will also allow you to grep your or other peoples source for this 
kind of cast, which is currently not possible at all in D, but is in C++.





More information about the Digitalmars-d mailing list