[squeak-dev] How to become immediate objects? :-)

Levente Uzonyi leves at caesar.elte.hu
Tue Apr 14 19:52:38 UTC 2020


Hi Eliot,

On Tue, 14 Apr 2020, Eliot Miranda wrote:

>
>
>> On Apr 14, 2020, at 6:40 AM, Levente Uzonyi <leves at caesar.elte.hu> wrote:
>> 
>> Hi Marcel,
>> 
>> That's a bug. The argument of #becomeForward: is never attempted to be modified. The following should work:
>> 
>> | a |
>> a := Object new.
>> a becomeForward: #foo.
>> self assert: a = 'foo'.
>> 
>> The error it raises is nonsense.
>
> +1

Well, the thing is that #becomeForward: tries to copy the identityHash too
hence the error. I'm not sure whether PrimErrInapropriate is the right 
choice but that's what the code produces and it matches what the comment 
of SpurMemoryManager >> #containsOnlyValidBecomeObjects:and:twoWay:copyHash:
states. IMHO PrimErrNoModification would be more appropriate in this case.

So, the presence of the error is expected. The correct code is:

| a |
a := Object new.
a becomeForward: #foo copyHash: false.
self assert: a = #foo.

Which works as expected.


Levente

>
>> 
>> 
>> Levente
>> 
>>> On Tue, 14 Apr 2020, Marcel Taeumel wrote:
>>> 
>>> Hi, all!
>>> I suppose that since ModificationForbidden and read-only objects, the following is no longer possible:
>>> MyExternalResource allInstancesDo: [:resource |
>>>    resource becomeForward: #notAvailable].
>>> What to do now? Introduce a custom, mutable, placeholder object instead?
>>> Best,
>>> Marcel
>>


More information about the Squeak-dev mailing list