Posted by
Esteban A. Maringolo-2 on
Jan 12, 2005; 7:32pm
URL: https://forum.world.st/become-and-oneWayBecome-tp3372645p3372648.html
Blair McGlashan escribió:
> "Esteban A. Maringolo" <
[hidden email]> wrote
>> reading the method comment of #oneWayBecome: it mentions about the
>>efficience of the implementation.
>>...
>>What kind of efficience does it refers?
> Time it and see, the difference will soon be evident.
> Swapping #become: performs a pointer swap (not exactly, but close enough)
> and is therefore virtually instantaneous. #oneWayBecome: scans the entire
> object memory, and is thus many orders of magnitude slower. In fact I would
> expect it to be too slow for implementing proxies.
Ok, there is the key. Thanks.
>>I'm using #oneWayBecome: to transform stubs (Subclasses of ProtoObject)
>>into concrete objects, the stubs represents "external objects" which are
>>loaded at demand.
>>But i'm not very sure about the "pointing" of the objects.
>>
>>E.g. objectA (concrete), stub1 (of objectB), stub2 (of objectA), stub3 (of objectA)
>>
>>If stub2 becomes the concrete objectA, so all what where pointing to stub2
>>now points to objectA. If I want to preserve identity and contents and
>>objectA, when stub3 becomes the existing objectA it should do it using
>>#oneWayBecome:, am I right?
> I'm not sure I understand the question.
Perhaps I have to take those english lessons once and forever :-D
> #oneWayBecome: replaces all references to the receiver with
> references to the argument.
This is what I want.
> [SNIP]
> #oneWayBecome: loses the identity of one object (the receiver).
That wouldn't be a problem, indeed i want to loose that object.
Because it will be used only once, once a message has been send to
it, it will transform (become) into another object or to nil*.
*It will lookup in the cache (if is loaded), in the external space
(whatever) and if it doesn't exists in any of those, will become nil
(it really doesn't exists externally)
> In the case of #become:, any collections containing the affected
> objects that are hashed by identity (e.g. an IdentityDictionary)
> will remain valid.
> This is not true of #oneWayBecome:, which will invalidate any
> hashed collections holding references to the "lost" object.
Can be this issue handled automatically, or have to be rehashed
explicitly?
Which can be very difficult if the object doesn't know who's holding
it, the case with all the collections e.g.
> It is, perhaps, easier to understand the behaviour of #become: if you think
> of an object as having an identity (or header) and a value (or body).
> #become: swaps the bodies over. #oneWayBecome:, on the other hand, replaces
> the identity of one object with another.
Yes... I think it in that way, that's why i want to preserve target
identity.
Is possible to make a trick to speed up the proccess of
#oneWayBecome: using a combination of #becomes:'s... or similar
>>What should I do if I want that all what points to anStub points to nil?
> You would have to use #oneWayBecome: for that. If you attempt to #become:
> anything to nil in Dolphin an error will be raised (no damage will be done).
Ok... so my problem now focues on how to speed up #oneWayBecome: or
assume that this is the way it works, and use it as it comes.
Thank you very much.
--
Esteban A. Maringolo
[hidden email]