Re: Tell Blocks Considered Harmful (was Re: open for access)
Re: Tell Blocks Considered Harmful (was Re: open for access)
- Subject: Re: Tell Blocks Considered Harmful (was Re: open for access)
- From: Chris Page <email@hidden>
- Date: Wed, 10 Dec 2008 20:37:52 -0800
On Dec 10, 2008, at 7:38 PM, Chris Page wrote:
On Dec 10, 2008, at 12:34 PM, Ed Stockly wrote:
Seriously, if it's not broke don't fix it.
Just because something appears to work now doesn't mean it doesn't
have unintended reliance upon things that have never been guaranteed
to remain the same.
A relavent item from another thread:
On Dec 2, 2008, at 4:13 PM, Jean-Christophe Helary wrote:
Is there a way to specify a text language without having to rely on
the International preferences ?
The reference for "word" indicates:
A continuous series of characters, with word elements parsed
according to the word-break rules set in the International
preference pane.
Because the rules for parsing words are thus under user control,
your scripts should not count on a deterministic text parsing of
words.
There are two observations I wish to make:
1. Scripts that are written using “word” and then only run with
whatever system language the script author happens to be using may be
said to “work”. But is the script doing what the author intended? Did
they intend the script only to work when their language is the system
language?
2. What would happen if we decided to improve the situation by
changing “word”, etc. to require an explicit language parameter? That
would probably break all the existing scripts that don't have that
parameter. Okay, what if we added support for an optional “using
language ...” block that affects all the language-dependent commands
inside? What should we do about existing scripts? Should we allow
“word” to continue relying upon the system language setting? Perhaps.
But that means new people come along and may continue to
unintentionally write scripts that still rely upon the system
language. How about if we record the system language when we compile a
script, so that that script continues to run with the same language,
ignoring the current system language, until that script is compiled
again? That might be a nice automatic solution, except that it will
break scripts that intentionally change the system language setting to
alter the behavior of “word”.
My point is that improving things is important and useful, and can be
challenging to do compatibly, especially if we can't tell what
existing scripts intended to do. Writing scripts that are as clear
about their intentions as possible helps everyone. Minimizing the use
of tell blocks in AppleScripts is one way to make intentions clearer.
--
Chris Page
The other, other AppleScript Chris
_______________________________________________
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