const?? When and why? This is ugly!

Walter Bright newshound1 at digitalmars.com
Sun Mar 8 19:28:00 PDT 2009


Steve Schveighoffer wrote:
> Walter: Use invariant when you can, it's the best!
> User: ok, how do I use it?
> Walter: You need to cast mutable data to invariant, but it's on you to 
> make sure nobody changes the original mutable data.  Casting circumvents 
> the typesystem, so the compiler can't help you.
> User: :(

Unfortunately, we could not come up with a typesafe scheme for going 
from mutable to immutable that was reasonable. The transition is up to 
the user to do correctly, but it isn't a terrible burden, and is simple 
to get right.



More information about the Digitalmars-d mailing list