Still trying to kill that pesky morph......

John Hinsley jhinsley at telinco.co.uk
Mon Oct 22 00:48:28 UTC 2001


Torge Husfeldt wrote:
> 
> Hear John,
> You don't need that number!
> The number is generated >from some internals of the morph when it is
> dropped on the workspace. Then the new binding is created for _this_
> workspace. I'm pretty sure that even if you guessed the right number you
> wouldn't be able to kill the morph with WorldTimeMorph12345 delete.
> Because there is no binding before. (This should be true for other
> workspaces even after you generated the textual representation).
> 
> On the other hand I'm pretty sure you do something like:
> WorldTimeMorph new
> somewhere in your code. Fine. Just make sure you change that to
> <myInstanceVariable> := WorldTimeMorph new
> and everything is fine.
> Now you can do:
> <myInstanceVariable> delete
> anywhere you want (that is: the instance variable must be visible
> there).
> No magic numbers involved.

I think what I was missing was that WorldTimeMorph (at least, the
initializeLocally part of it) is all class side and thus won't behave
like "normal" morphs in this respect. Hence my messing about with magic
numbers. 

But, try it: if you do drop a WorldTimeMorph on a workspace you can then
use the generated "textual reference" (worldtime + the magic number) and
delete works fine on that. The problem then becomes one of obtaining
that number reliably! -- some kind of way of getting that from a
workspace might be useful, though.

Still, Ned's line 

World allMorphsDo: [ :ea | (ea isKindOf: WorldTimeMorph) ifTrue: [ ea
delete ]]

does the trick very nicely indeed. 

Thanks

Cheers

John


-- 
If you don't care about your data, like file systems which automagically
destroy themselves and have money to burn on 3rd party tools to keep
your
system staggering on, Microsoft (tm) have the Operating System for you.




More information about the Squeak-dev mailing list