Re: script object property contamination
Re: script object property contamination
- Subject: Re: script object property contamination
- From: "Serge Belleudy-d'Espinose" <email@hidden>
- Date: Thu, 14 Feb 2002 13:52:16 +0100
At 13:37 +0000 13/02/02, has wrote:
This behaviour disturbs me. It's clearly has nothing to do with the
inheritance mechanism, so there's clearly something strange going on. It's
as if the get_first_global now has some sort of 'ancestral memory' that it
takes with it on its travels to aParent. Even though it's now in a
*completely different* context, it somehow seems to worm its way back to
fetch the contents of Grab_globals_Test. [I could hypothesise what's
happening here, but it'd be pure guesswork and little practical use.]
Just by the time when working on my ongoing project leads me to the
same conclusions. I'm currently playing with several examples
involving objects created in different ways, juggling with
properties/handlers/objects- which mostly behave the same- and the
keywords always are *context at compile time*. See a few- 'only' 4!-
examples below:
-- example #1
script a1
property c : 4
on d()
get c -- here c is not necessary, adding it is harmless
end d
end script
tell a1 to d() --> 4, ok (of course!)
-- example #2
script a2
property c : 4
property d : missing value
end script
on d()
get c
end d
tell a2
set its d to d
its d() --> error, c is not defined
end tell
-- example #3
script a3
property c : 4
property d : missing value
end script
script a4
on d()
get c
end d
end script
tell a3
set its d to d of a4
its d() --> same error, but in the next example...
end tell
-- example #4
script a5
property c : 4
property d : missing value
end script
script a6
property c : 5
on d()
get c
end d
end script
tell a5
set its d to d of a6
its d() --> ...4, ok, just because we added c in a6
end tell
-- (sorry for being that long!)
#2 and #3 are failing because, at compile time, there was no c
outside of d, so d won't work even once inside a2/a3. #4 _seems_ ok,
but if a5 and a6 don't hold the same set of properties, or they are
laid in differents orders, the nasty bug comes back. All of this can
be avoided with proper use of 'my/of me.'
Speaking for myself I would avoid using globals by any mean, even for
fixing reasons. Better understand what you use before using something
else you don't control as well.
Serge
--
\\//\//\// Serge Belleudy-d'Espinose Institut Jacques Monod - Jussieu
// // //
http://www.ijm.jussieu.fr/ Universites Paris VI, VII - CNRS
//\//\//\\
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.