One should always be *able* to unsubscribe, but it should not be required. Squeak's weak collections do not measure up to the competition. Please take a look at my 1/2/2010 post "RE: [Pharo-project] Can't debug in 1.1". I doubt SharedLookupTable could be called efficient, but it solved some problems I was having due to the current implementation. I welcome concrete examples of how horrible it is, and offer it up as a starting point or simple inspiration for something more useful. Bill -----Original Message----- From: pharo-project-bounces@lists.gforge.inria.fr [mailto:pharo-project-bounces@lists.gforge.inria.fr] On Behalf Of Henrik Sperre Johansen Sent: Thursday, January 07, 2010 6:57 PM To: pharo-project@lists.gforge.inria.fr Subject: Re: [Pharo-project] Notifications of windows opening/closing/focus On 07.01.2010 14:50, Schwab,Wilhelm K wrote:
Gary,
If announcements are at all what I am expecting (perhaps a non-trivial assumption??), then I doubt it will be a problem. One would observe the world/window-manager for open events, and then express interest in events from individual windows. That might turn out to be easier on consumers than getting everything from one source. Cleanup should be trivial if the announcement framework uses weak references.
Bill
The Pharo implementation does not include weak announcement subscriptions, you have to manually unsubscribe if you need to. This can be solved in VisualWorks without keeping a list of whom you are subscribed to, by using the fact that the block in subscribe:do: can take 2 args instead of one, in which case the second argument is the announcer. If this were the case in the Pharo/Squeak implementation, the Global WindowOpened/Local InterestingWindowEvents could be written: (receiveAnnouncements to true in initialize, false in release) SystemWindow openAnnouncer subscribe: WindowOpened do: [:ann : | ann window satisfiesMyCriteria ifTrue: [ ann window subscribe: InterestingWindowEvent do: [:ann :announcer | receiveAnnouncements ifTrue: [self handleInterestingEvent: ann] ifFalse: [announcer unsubscribe: self]] Not very pretty, but still better than the alternative if you know the dynamic announcer is likely to outlive the consumer. Cheers, Henry _______________________________________________ Pharo-project mailing list Pharo-project@lists.gforge.inria.fr http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project