[squeak-dev] Object new becomeForward: #normal
Eliot Miranda
eliot.miranda at gmail.com
Wed Jul 19 18:10:36 UTC 2017
On Tue, Jul 18, 2017 at 2:10 PM, Bert Freudenberg <bert at freudenbergs.de>
wrote:
> On Tue, Jul 18, 2017 at 10:03 PM, Eliot Miranda <eliot.miranda at gmail.com>
> wrote:
>
>>
>> I'm modifying the Spur VM to fail becomeForward: when copyHash is true
>> and the target object is immutable. So when we have immutable literals,
>> #normal would be immutable and the become would fail.
>>
>
> +1
>
>
>> However, it seems to me that becomerForward: doing a copyHash is itself a
>> bug. What's the rationale for copying the receiver's hash to the target
>> object? I've seen various frameworks use become to clean-up objects by
>> doing aNoLongerWantedObject becomeFor4ward: nil, and with our current
>> default implementation for becomeForward: that will cause havoc.
>>
>
> Well, it would mean nil's identityHash changes. But since nil isn't
> typically used as key in hashed collections, that use may be fine?
>
Maybe but in Spur I doubt it :-)
#(nil false true) collect: [:ea| ea identityHash] #(1 2 3)
> I agree that the becomeForward: default should be to not copy the hash.
> This could be done in the image though, no need to change the primitive.
>
Changing the primitive is not an option as it breaks VM backward
compatibility. But adding another primitive that implements the desired
default is quite straight-forward and then the image can use whichever it
chooses without having to add another indirection.
_,,,^..^,,,_
best, Eliot
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20170719/1f848ae5/attachment.html>
More information about the Squeak-dev
mailing list
|