destructors, how?
Peter Crowther
Peter.Crowther at networkinference.com
Tue Oct 22 14:55:39 UTC 2002
> From: Ragnar Hojland Espinosa [mailto:ragnar at linalco.com]
> I want to automatically call self terminate on an object on
> destruction (or when it goes out of scope..)
Smalltalk objects are not 'destroyed'. They are garbage-collected at
some time after no other object references them. The 'some time after'
could be microseconds or days.
> I can't find out how to write a destructor
> or something functionally equivalent.
Check out implementors of 'finalize' (IIRC). In essence, you hold onto
the object using a weak array; are notified when it is
garbage-collected; and clear appropriate fields based on copies of the
data in the object.
- Peter
More information about the Squeak-dev
mailing list
|