On Wednesday, 9 January 2013 at 17:22:25 UTC, ollie wrote:
My question is about immutable and casting in general. I've heard Walter say of immutable, "Turtles all the way down.". If say I have a plug-in system with a defined interface and I pass it an immutable array (ie immutable(int)[]) then it uses a cast to mutate, that seems to defeat the purpose of immutable. When the plug-in returns, I now have an immutable array that has been mutated. Is this how immutable and casting are
supposed to work?

Seems you are raising two different issues:

"Turtles all the way down" means the immutability is transitive.

For example, an "immutable(int*)" means both the pointer AND
pointee are immutable. This is in contrast to C++, where you can
have a const pointer to non const data. This is impossible in D.

As for the cast question: Casting is a means to do *anything* you
want, no guarantees. If you want to do something illegal, there's
no one left to stop you. Not really any different from C++
actually.

Reply via email to