One of the uses of weak references in other languages is to keep a collection of all the instances of a class without preventing them being garbage collected. Obviously, this is not necessary in squeak.
On 7/15/08, Herbert König herbertkoenig@gmx.net wrote:
Hello cdrick,
c> All that sounds like "don't use weak reference" :)
.... unless you know exactly what you are doing.
-- Cheers,
Herbert
Beginners mailing list Beginners@lists.squeakfoundation.org http://lists.squeakfoundation.org/mailman/listinfo/beginners
Am 15.07.2008 um 06:42 schrieb Marcin Tustin:
One of the uses of weak references in other languages is to keep a collection of all the instances of a class without preventing them being garbage collected. Obviously, this is not necessary in squeak.
One major use in Squeak is for ensuring that system resources (such as file handles) are released when a file object is garbage-collected. Note this is only a fall-back, you should still use #close on files, but to prevent resource leakage in odd cases, a weak reference is held to each open file.
It's one of the low-level implementation details that exist to make the normal live of a Smalltalk programmer simpler. Only the framework designer interfacing to non-Smalltalk objects (such as files) needs to worry about it. I've never seen a need for weak references in application-level code.
- Bert -
beginners@lists.squeakfoundation.org