[Newbies] Get rid of an object

Randal L. Schwartz merlyn at stonehenge.com
Tue Feb 2 01:06:14 UTC 2010


>>>>> "lanas" == lanas  <lanas at securenet.net> writes:

lanas> Now, if I 'do it' once more on the first line the inspect window will
lanas> still show the same variables being set.

It's inspecting the old object, yes.

lanas>   If I open another inspect window on myCar I get the new object,
lanas> without any variables yet set.

It's another object, distinct from the previous one.

lanas> So it looks like objects of the same name are considered separate
lanas> entities.

No, the first one no longer has a name.  The inspector has a reference
to it, though.

lanas>   I'd have thought that perhaps doing a 'do it' on myCar a
lanas> second time would have re-initialized the first existing object.

No.  You created a new car, then gave it the name "myCar" in the current
workspace, completely releasing any previous object that myCar might have
referenced.  The thing to get is that when you say:

    x := y

then any thing that was previously in x cannot be affected.  The assignment is
always performing a new binding to a new object.

lanas> If I create 25 myCar for various tests, then there'll be 25 myCar
lanas> objects laying around in the image ?  How to get rid of them ?

Garbage is collected constantly by a background process. You can force it, but
there's generally no need.  Your car bits will eventually be recycled bits. :)

-- 
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn at stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Smalltalk/Perl/Unix consulting, Technical writing, Comedy, etc. etc.
See http://methodsandmessages.vox.com/ for Smalltalk and Seaside discussion


More information about the Beginners mailing list