cast(!const) proposal

Don Clugston dac at nospam.com.au
Sun Sep 9 13:02:24 PDT 2007


Lutger wrote:
> 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++.
> 
> 
My earlier proposal was:
cast(break const)
for essentially the same thing. But we really need something for this, whatever 
the syntax.



More information about the Digitalmars-d mailing list