Re: Globals are considered harmful (was Re: Recursion script which doesn't?)
Re: Globals are considered harmful (was Re: Recursion script which doesn't?)
- Subject: Re: Globals are considered harmful (was Re: Recursion script which doesn't?)
- From: "Serge Belleudy-d'Espinose" <email@hidden>
- Date: Sun, 8 Apr 2001 11:40:42 +0200
At 10:35 -0700 7/04/01, Paul Berkowitz wrote:
>
The thing is: although theoretically persistent, globals have to be set to
>
be used, otherwise they error as undefined variables. So the next time you
>
run the script, they are automatically reset to the original setting, and
>
are thus effectively not persistent. You can't even start out
>
>
if someGlobal "" then
>
--do something
>
else
>
set someGlobal to something
>
end if
Coincidentally, I just found that you can use this in a script:
try
set myVar to ... -- anything you want with myVar, such as myVar + 1
on error
set myVar to ... -- initial value
end
What's the point of using this?
- a property is persistent and global
- a global isn't persistent but... global
- myVar is not global, but persistent anyway
I think myVar fills a gap between properties and globals.
I'm pretty confident others have found this also. But as this "discovery" is new to me, I just wanted to share it.
Serge
--
\\//\//\// Serge Belleudy-d'Espinose Institut Jacques Monod
// // //
http://www.ijm.jussieu.fr/ Univ. Jussieu - Paris
//\//\//\\