Event triggering and weak references

Ricardo Nogueira rnog2438 at mail.usyd.edu.au
Sun Apr 16 17:13:35 CEST 2000


First thanks for this beautiful language : )

I am Smalltalk addicted : )  and this means that I can't do with any other
language, ex. C, C++, Java,  : (
This was true until I found Python 2 weeks ago at Sydney Uni. I loved its
modularity, pluggin behaviour and freedom.
But I am missing Smalltalk event handling... Smalltalk (like Python) support
the call-Back mechanism, but there is a more powerful inter-object interest
registering that I haven't found in Python (so far).

This is what I would like to do:
Imagine I could have two or more Widgets open displaying a car speed value,
say a numerical and a graphic display, if this car speed changes (ex. some
one pushes the break), I would like to have any open widget on this value
updated (on opening each window would register interest with this car
speed).

Smalltalk implements this with:

The widget would register interest in one aspect of the car  (on opening
over aCar):
  aCar when:#speedChanged send: #updateSpeedDisplay to: self

And the car would just notify who is interested, if any (when its speed
changes):
  self trigger: #speedChanged

But if any of this windows is not referenced anymore or crashes I would like
the garbage collector clear it (the car would not be notified and his
pointer to the window shouldn't keep the garbage collector form freeing the
window memory).

Again, Smalltalk implements this with weak references, that doesn't count
for the garbage collector.

Is there support for this in Python?

Any suggestions?





More information about the Python-list mailing list