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

Walter Bright newshound1 at digitalmars.com
Mon Jun 18 02:19:55 PDT 2007


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.



More information about the Digitalmars-d mailing list