Steven Schveighoffer: > D would not allow you to pass a .ptr field of an immutable string, because > the type would be immutable(char)* and wouldn't implicitly cast to the > required char* argument. Casting, however, would mask that problem and > probably overwrite immutable data (and probably segfault on Linux). > Another example of why casting is bad.
Casting is dangerous in general, but it becomes less dangerous when you have some different specialized casts: if you have a cast syntax that only change the const-ness of something (mutable <-> const <-> immutable), and a different syntax (syntax = "any way to express a semantics") to change other aspects of the type, it becomes less easy to cast const-ness away by mistake. Bye, bearophile
