Re: Functions as a sort of first-class objects
Re: Functions as a sort of first-class objects
- Subject: Re: Functions as a sort of first-class objects
- From: has <email@hidden>
- Date: Thu, 26 May 2016 20:30:32 +0100
Rob Lewis <email@hidden> wrote:
On May 26, 2016, at 07:00 , email@hidden wrote:
But… things tend to become muddier, because of the very special handling of global variables in AppleScript.
I would love to know the definitive story on this! Where is it documented?
Variable scoping is documented in:
https://developer.apple.com/library/mac/documentation/AppleScript/Conceptual/AppleScriptLangGuide/conceptual/ASLR_variables.html
It's inadequate and incorrect, of course, but what did you expect? This
is AppleScript, after all. The globality of top-level variables that
aren't explicitly declared `global` or `property` also falls into that
"undefined" territory I was talking about earlier. It's certainly not
something you should intentionally exploit; OTOH, it can cause just
enough troubles (e.g. applets that fall down when trying to resave their
current state before quitting) that you probably ought to be aware of
it. And AS globals are themselves a language misfeature, as they don't
serve any purpose that properties already serve while also creating
various exciting new ways to create incredibly obscure and
horrendous-to-debug misbehaviors (since they completely ignore
namespacing, even across completely unrelated library objects).
As with learning, say, JavaScript, half the challenge of mastering
AppleScript is figuring out what the heck everything does (further
compounded by AppleScript and its documentation's absolute delight in
endlessly lying to you about how it actually works in order to be
"helpful"), while the other half is figuring out which of those
'features' are ridiculously brain-damaged and to be avoided like the
plague. Basically, use locals, use properties, beware of top-level
'locals' because they aren't really, and never touch the `global`
statement with a bargepole because that way only sorrow and humiliation
lies.
Also, in all this discussion I’ve seen no mention of handlers that have parameters. Does that change the picture?
No. Parameters are parameters.
Unless, of course, they're direct parameters to a keyword-based command,
in which case… oh, unless you want my brains dribbling all over your
shoes, you get the idea already.
Stupid wonderful incompetent delightful *insanely* frustrating language.
Were it not for the even more laughable fact that every single one of
its rivals has immediately/eventually thrown themselves on their own
swords through their own even greater ignorance and/or ineptitude, its
ass would've been roundhouse-kicked out of the room long long ago.
(Honestly, if someone wants to start an AppleScriptaholics list where
folks can go to compare Stockholm syndromes and the number of times
they've fallen off the wagon this week, bagsy I'm in first.;)
HTH
has
_______________________________________________
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