more adventures of a smalltalk newbie

Bob Arning arning at charm.net
Tue May 9 02:14:16 UTC 2000


Hi David,

On Tue, 9 May 2000 01:01:56 +0100 "david gentle" <davidgentle26 at freeuk.com> wrote:
>I think I begining to get the hang of the syntax.
>Now. I have a couple of questions:
>a: how do you draw a line?

There are several methods that will help here. See FormCanvas>>line:to:width:color: e.g.

>b: how do you get rid of an instance once you've created it? Or do you get
>rid of it? I'm assuming it doesn't just hang around like the smell of 8 day
>worn socks?

Here you are in for a pleasant surprise - little or no effort is required on your part. Once the instance in question is unreachable it is garbage collected automagically. Sometimes you may want to hurry things along (if the instance is big, referenced by something long-lived and you need the memory now). For example:

Suppose you have a method that runs for a long time:

	| var1 |
	"step 1" var1 _ SomethingBig new.	
	"step 2" var1 doSomethingInteresting.					
	"step 3" self spendALongTimeDoingSomethingElse.		

var1 will be garbage collected when the method ends, but if you really need the memory back after step2 then you could insert

var1 _ nil.

between steps 2 and 3 to remove the reference held by this method.

Cheers,
Bob





More information about the Squeak-dev mailing list