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

Sean Kelly sean at f4.ca
Mon Jun 18 07:47:34 PDT 2007


Walter Bright wrote:
> Brad Roberts wrote:
>> If it's actually treating the string as read-only, then I'd be tempted 
>> to change the extern(c) declaration to pass the argument as const char 
>> * rather than casting away the invariantness.
> 
> The need to be able to cast away const-ness is to interface to libraries 
> that you cannot go and change.
> 
> Also, the type system is not meant to be a straitjacket. If you 
> absolutely must do something, and you know what you are doing, there 
> should be a way to do it.

That's understandable, but isn't it contrary to your statement that 
const in C++ is useless because of const_cast?  Or is it the presence of 
a cast specifically intended to cast away const that you take issue with?


Sean



More information about the Digitalmars-d mailing list