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

Eliot Miranda eliot.miranda at gmail.com
Tue Apr 14 20:44:29 UTC 2020


Hi Levente,

On Tue, Apr 14, 2020 at 12:52 PM Levente Uzonyi <leves at caesar.elte.hu>
wrote:

> 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.
>

Right.  A couple of questions are
1. what the f**k are become: becomeForward: becomeForward:copyHash: et al
doing in ProtoObject?  (IMO, they should be in Object and have no business
being in ProtoObject whatsoever).
2. whether becomeForward: should do copyHash: true by default.  This seems
wrong to me, and implementing is as copyHash: false makes more sense.  But
I'm wondering if there are important use cases.  Vanessa, any recollections
on this?

But the VM bug is here in
SpurMemoryManager>>containsOnlyValidBecomeObjects:and:twoWay:copyHash:

    (copyHash and: [(self isImmediate: oop2) or: [self isImmutable: oop2]])
ifTrue:
[^PrimErrInappropriate].

it should read something like
    copyHash ifTrue:
[(self isImmediate: oop2) ifTrue:
[^PrimErrInappropriate].
(self isImmutable: oop2) ifTrue:
[^PrimErrNoModification]].

I'll make it so.

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
> >>
>


-- 
_,,,^..^,,,_
best, Eliot
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20200414/7c7ec8e9/attachment.html>


More information about the Squeak-dev mailing list