[squeak-dev] Object new becomeForward: #normal
bert at freudenbergs.de
Tue Jul 18 14:30:59 UTC 2017
On Tue, Jul 18, 2017 at 4:09 PM, Levente Uzonyi <leves at caesar.elte.hu>
> On Tue, 18 Jul 2017, marcel.taeumel wrote:
> Hi, there.
>> Why are there guards to prevent forward-becoming to immediates (chars,
>> but not to symbols?
> The former is technically impossible due to different object
> representations, the latter is possible and not restricted at all. For
> example, true and false are not immediate objects, you can use #become*: on
> them to blow your image up.
> So, there's no restriction at all if it's technically possible to use
> The responsibility model is the simplest here: use at your own risk.
> Since this comes up every once in a while, I suggest a comment be added to
> those methods stating the responsibility model explicitly.
*Especially* a warning that becomeForward: does modify the target's hash.
> I don't know how the VM handles immutability in this case, but it's
> possible that it wouldn't let #become*: affect immutable objects.
I think that would be fine, you should be able to become an immutable
object and vice versa.
> On the other hand, I'm sure it would let you change fields of immutable
> objects via #become*:, but that's not an issue in your case.
This is debatable ... I would rather have the VM raise an error when
trying to become a field of an immutable object. Immutable should mean
- Bert -
>> This will break your image: "Object new becomeForward: #normal"
>> ... because Cursor class MNU #normal ... :-) Either this is a bug or
>> forward-becoming to symbols is not intended at all.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Squeak-dev