How to use sprintf
bearophile
bearophileHUGS at lycos.com
Tue Apr 26 10:39:52 PDT 2011
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
More information about the Digitalmars-d
mailing list