WeakMessageSend event registration doesn't work with transient arguments (was [Q] Morphic Color Problems)

Ned Konz ned at bike-nomad.com
Mon Jun 16 03:13:10 UTC 2003


On Sunday 15 June 2003 05:19 pm, Chris Burkert wrote:

> This seems to be definitly a bug, or not?

Well, it's an "interesting behavior" of the event system.

r := RectangleMorph new openInWorld.
o := Object new.
o when: #a send: #color: to: r with: (Color black alpha: 0.3).

o actionsFor: #a
	answers nil.

(o actionMap at: #c) isReceiverOrAnyArgumentGarbage
	answers true.

The problem is that the WeakMessageSends we're using (well, my name is 
all over this, so I guess I'm responsible) hold on to their receiver 
*and* their arguments weakly.

So "Color black" works, but "Color black copy" wouldn't (same with 
"Color black alpha: 0.3" or any other transient object.)

We've discussed this at length in the past (like back on February 9) 
and never really did anything about it.

From that discussion:

On Sunday 09 February 2003 04:36 pm, Robert Withers wrote:
> On Saturday, February 8, 2003, at 02:47 PM, Bob Arning wrote:
> > Maybe, maybe not. It might be plausible for an object to expect
> > notification from an event even if that event is the only
> > reference to the object. Might be nice to have an option for
> > strong or weak MessagesSends.
>
> I agree, but not by default.  By default, it shouldn't be the
> source of uncollected garbage, and would require you to hold onto
> things involved in an event activation.   This is a rather strongly
> held opinion of mine, unfortunately.
>
> Ned and I did discuss at great length the necessity of having the
> capability to strongly hold references.  In fact, his Connectors
> package overrides the default behavior and does hold them strongly.
>
> IIRC, we discussed some extension event registration protocol that
> would allow you to specify 'use strong references' (what should the
> keyword message be?).  The really desirable mechanism would be to
> specify the reference strength for the receiver and each argument
> (as well as whether the registration argument or the trigger
> argument would be selected).  This mechanism would be something
> equivalent to a mask of bits, or another extension to the
> #when:send:to:withArguments: that would provide for this user
> control over the event mechanism.

For now, just have some object hold on to the colors and it should 
work fine.

-- 
Ned Konz
http://bike-nomad.com
GPG key ID: BEEA7EFE



More information about the Squeak-dev mailing list