|
HBSteinberg,
> Can anyone give me a hint what has changed from D5 to D6 workspaces and
> how deal with this?
From the Dolphin 6 "What's new"
~~~~~~~~~~
We've now made all compiler generated literal objects immutable, and any
attempt to write to them will result in a Attempt to update read-only
object error.
In addition, you can also mark any other object as immutable by sending
it an #isImmutable: message with true as the argument. You might want to
do this for shared constants variables such as class variables. Should
you need to modify an immutable object then the Object>>whileMutableDo:
method can be used to temporarily disable immutability while a block is
executed.
The immutability mechanism can also be used as a guard mechanism to
detect dirty objects since the VM now sends #errorInstVarAt:put: to an
immutable object if one attempts to assign to its named instance variables.
~~~~~~~~~~
So if you use a literal constant in a method (or workspace) you can't
alter it. To work around it you could use the #whileMutableDo: method
mentioned above
firstname := 'Bob'.
firstname whileMutableDo: [firstname at: 1 put: $R].
or, possibly easier, copy the literal into another (non literal) String....
firstname := (String withAll: 'Bob') "; not needed"
at: 1 put: $R;
yourself
Note the #yourself that would be needed (on the D5 version as well) to
get the code to work as expected.
--
Ian
Use the Reply-To address to contact me (limited validity).
Mail sent to the From address is ignored.
|