[Q] dependency in morph

Ned Konz ned at bike-nomad.com
Fri Sep 6 18:59:53 UTC 2002


On Friday 06 September 2002 11:41 am, Stephane Ducasse wrote:
> Ned
>
> I'm confused. I'm planning to use that for my book which is in 3.2
> so is it working or not?

Well, I _think_ it's working, but if you're not careful (if you don't 
unregister the events) it can keep your morphs from being GC'd. The 
old dependents mechanism used a Weak collection already, so this 
wasn't a problem.

I could post an update (with my WeakMessageSend class substituting for 
the MessageSend that's currently used) that would fix this problem.

Perhaps it would be best to ask Rob Withers what's happening with the 
events code.

On April 24, Rob said:

> This weekend, I hope to continue with the WeakMessageSend we were
discussing, for the receivers and args.  How does the finalization
mechanism work?  Will it nil out garbage slots?

I don't know if he actually finished it, though.

> On vendredi, septembre 6, 2002, at 08:34  PM, Ned Konz wrote:
> > On Friday 06 September 2002 10:35 am, Stephane Ducasse wrote:
> >>> I would like to propagate change between two object.
> >>> I used the old changed:, update mechanism
> >>> but I ended up writing
> >>>
> >>> Myclass>>update: aSymbol
> >>>
> >>> 	aSumbol =#zork
> >>> 		ifTrue: [self m1. ^ self]
> >>> 	aSymbol = #zarf
> >>> 		ifTrue: [self m2. ^self]
> >>>
> >>>
> >>> Is there a better in morph to do the same
> >>>
> >>> I was looking for something like
> >>>
> >>>
> >>> 	self when: methodX perform: #m2 on: aMyClass
> >>>
> >>> Is there something like that because this would be better for
> >>> my book but I could not find it.
> >
> > Well, there's all the methods in the Object "events" category.
> > For instance, you could do this in the observer:
> >
> > someMorph when: #zork send: #m1 to: self.
> > someMorph when: #zarf send: #m2 to: self.
> >
> > and in someMorph:
> >
> > self triggerEvent: #zork.
> >
> >
> > However, I'm a bit concerned that the actionSequence registration
> > will hang on strongly to both the observer and the observed
> > objects. It uses MessageSends. I wrote WeakMessageSend to fix
> > this problem in the event mechanism, but I see that it hasn't
> > been used yet (at least in 3.2).
> >
> > This may have been an oversight.
> >
> > It may be worth looking at the events implementation in 3.3 to
> > see if we need to back-port the events code to 3.2.
> >
> > --
> > Ned Konz
> > http://bike-nomad.com
> > GPG key ID: BEEA7EFE
>
> Dr. Stéphane DUCASSE (ducasse at iam.unibe.ch)
> http://www.iam.unibe.ch/~ducasse/
>   "if you knew today was your last day on earth, what would you do
>   different? ... especially if, by doing something different, today
>   might not be your last day on earth" Calvin&Hobbes

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




More information about the Squeak-dev mailing list