On Sat, Aug 20, 2011 at 04:41:08PM -0700, Darren Duncan wrote: > I believe the general solution to this problem is to make all > objects immutable, with the only exception being explicit > references, and so mutating an object isn't an option; rather you > have to derive a new object. > > "Values" of all types should be immutable, even if that type is > Array or whatever, and only "Variables" should be mutable. > ...
To make sure I understand correctly, you're essentially saying that @a.push(3) should not modify @a directly -- someone would have to write something like @a = @a.push(3) # or @a .= push(3) And to do a "shift", one would have to do something like ($value, @a) = @a; since @a.shift would be unable to mutate the array. (I'm not exactly sure what pop would look like.) Is that correct? Pm