Walter Bright wrote:
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.

In fact, since we last discussed that, dmd technology has made enough strides (particularly wrt manipulation of copies) that we can define Unique!T and something a la Java's StringBuilder with ease. Unfortunately current bugs in constructor implementation delay definition of such artifacts.


Andrei

Reply via email to