Still trying to kill that pesky morph......
jean-jacques.gelee at gmx.de
Mon Oct 22 09:11:17 UTC 2001
I think the other answers all very much sorted out your problem.
But i still want to insist that the *magic number* won't help you.
open two workspaces.
tell both to create textual references on drop
drop any morph on one of them
inspect the textual reference in the _other_one_
I'm pretty sure your inspector will show you an undefined Object.
Why is this?
What you're looking for is the identity of the morph.
The workspace has a special feature called local bindings (or so).
By this you can refer to Objects textually, just like local or temporal
When a morhp is dropped the workspace gets to know the identity (by th
It then creates a new binding by 'thinking of' a name and binding it to
There is no such thing as a global name for every Object. Allthough
there are global names for some Objects (Like World, ...). Any Object is
reachable in one way or the other >from one of these globally visible
Objects (otherwise it would get garbage collected). This is why you
nearly allways will find a way to wade all the Objects some of the
globals know and find your desired object. But this is almost never the
right way to go.
John Hinsley wrote:
> 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
> 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.
> 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
> system staggering on, Microsoft (tm) have the Operating System for you.
More information about the Squeak-dev