Re: difference between property and variable
Re: difference between property and variable
- Subject: Re: difference between property and variable
- From: has <email@hidden>
- Date: Tue, 11 Dec 2007 11:52:05 +0000
deivy petrescu wrote:
Up to properties Has is absolutely right.
Including and after properties I'm absolutely right as well.
First, lets not talk about script objects.
The OP asked what the differences between different types of variables
are. You can't avoid talking about script objects when discussing
property and global scope; however, I did say these differences could
be ignored unless the OP was using additional script objects for
modules/OOP, which I'm assuming they aren't.
Global as the name implies are defined globally, but, and it is a big
but, you have to declare that a handler will use that global.
*Only* if there isn't a top-level global declaration. If there is, you
don't need to redeclare the global in each handler that uses it.
(There is one additional caveat that, because the AppleScript compiler
sucks at binding variables statically, you'd better put the
declaration at the top of the script if you want it to bind correctly.
The same is true with property declarations, btw. See: warts.)
Also, in AS, using SEditor, any variable declared at the top of the
script is, by default, global.
Correct; but due to another language defect these variables aren't
properly bound at compile-time, which is why they aren't normally
accessible from anywhere else. However, as I said before, I wasn't
going to list all of the language's warts here as it doesn't help folk
who are still trying to get their heads around the core concepts.
...
Mark J. Reed wrote:
Apart from weird implementation-related performance differences, I
consider the most important distinguishing feature of properties to be
that they keep their values between executions (if the script is not
recompiled in between, anyway).
Global variables have the same persistency as properties in this
context.
(Also, there's another long list of caveats and clarifications to the
above, but I'm not going into those here.)
has
--
http://appscript.sourceforge.net
http://rb-appscript.rubyforge.org
_______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users
This email sent to email@hidden