Login  Register

Re: #become: and #oneWayBecome:

Posted by Chris Uppal-3 on Jan 13, 2005; 7:13am
URL: https://forum.world.st/become-and-oneWayBecome-tp3372645p3372657.html

Esteban A. Maringolo wrote:

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

If you are using proxies, then I don't think that using nil to mean "there was
no data" is a very good design (even if you could implement it).  It means that
client code will suddenly see an object (the proxy) that they legitimately
expect to respond to one protocol (the protocol understood by the "real"
objects) change into a different object that responds to a completely different
protocol.  That would (at least) make the client code very complicated.

I suggest you consider using an explicit "No Data" object -- an object that
"knows" that it represents a gap in the data, but which responds sensibly to
the normal protocol.   E.g. you'd have Customer objects that know their #name
and which answer false to #isBlank, and BlankCustomer objects that answer nil
to #name and true to #isBlank.  And you'd have CustomerProxy objects that would
turn (magically) into a Customer or into a BlankCustomer.

> Is possible to make a trick to speed up the proccess of
> #oneWayBecome: using a combination of #becomes:'s... or similar

I don't believe so.   And if there was, surely Blair would be using the trick
to speed up #oneWayBecome: in the VM already ;-)

I'm not sure if this is an actual /proof/ that you can't implement
#oneWayBecome: with #become: (and some temporary objects too, perhaps), but it
sounds persuasive to me:  Since #become: never decreases the number of object
references in existence, and creating temporary objects can only increase the
number of references, it seems to follow that they can't be used to implement
#oneWayBecome: since that /decreases/ the number of references by one.

    -- chris