Re: Handlers in a variable
Re: Handlers in a variable
- Subject: Re: Handlers in a variable
- From: has <email@hidden>
- Date: Mon, 18 Jan 2016 20:04:12 +0000
Ed Stockly wrote:
This works.
Sure it does. It's the delightful consequence of the unintended
intersection of a design misfeature (implicit/explicit `run` handler
variable declarations are *global variables* by default) and an
undefined behavior (handler objects can be reassigned to other slots
even though this is totally undocumented, unsafe, and a great way to
break everything). A well-designed language would have neither
misfeatures nor undefined behaviors, but one could never accuse
AppleScript of being that.
The sensible, safe, *sane* thing to do here is: DON'T DO THAT. It's a
basic lesson that all C, PHP, and AppleScript users ought to have
drilled into them from Day One, for both their own and their users'
safety, because until they have mastered it they are simply not
competent in the use of such brittle, unsafe tools. Yeah, flawed tools
suck. Blame the toolmaker. But sometimes flawed tools are what we're
stuck with, in which case we have to learn how to use them - and, even
more importantly, how NOT to use them - *safely*.
Frankly I'm a bit peeved that Chris P - who *should* know better - is
encouraging this nonsense: all he's doing is feeding his own users rope
to hang themselves[1]. If Chris really wants AppleScript handlers to
operate as first-class closures then he should go implement it first[2],
*then* he can safely expound on all its wonderfully interesting
crevasses to his heart's content. Otherwise, this whole topic is just
the sort of noxious nerd bait that brings out the worst kinds of
dangerous stupid in ostensibly intelligent, highly educated individuals,
while also leading those who haven't the training and experience to know
better straight into unmarked minefields. Know your product, know your
users, and please don't do either such a disservice.
has
[1] Here's a classic illustration, fresh off the idiot press:
<http://stackoverflow.com/questions/34833922/c-equivalent-to-applescript-tell-x-to-open-y>.
(No prizes for guessing who predicted the inevitable outcome to the
well-meaning but unthinkingly dangerous answer that got posted first.)
This is not an isolated example either: such passing on of dangerous
incompetence as wise folk wisdom is endemic in popular programming
culture. See also: every SQL injection attack ever, and reflect on the
fact that these sorts of reckless incompetents frequently call
themselves qualified professionals, and merrily build many of the
systems into which the rest of us so blithely enter our personal and
financial details.
[2] Although, as I've already stated, if Mr Page has that much spare
time to burn there are numerous other fixes and improvements he could be
making that would be *infinitely more valuable to all AS users*: decent
list performance, stack traces in errors, a standard library of
frequently needed commands. Not nearly so exciting for him as deep
interpreter hacking, but if that's what he want to be doing then he
ought to ask himself in whose interests he's really doing it.
_______________________________________________
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