on synonyms and homonyms (Re: Efficiently using whose on Address Book users)
on synonyms and homonyms (Re: Efficiently using whose on Address Book users)
- Subject: on synonyms and homonyms (Re: Efficiently using whose on Address Book users)
- From: has <email@hidden>
- Date: Mon, 23 Feb 2004 21:31:38 +0000
Paul Berkowitz wrote:
I guess it's a personal preference. The AppleScript
singular-property-of-plural-elements doesn't really have any exact
correspondence in English
Source code is written for the benefit of human readers, not
machines. The compiler doesn't give a fig if you make it
human-readable or not as long as it can parse it into legal
instructions. AppleScript's "every <class> of" vs. "<elements>'s"
stuff is merely syntactic sugar, there to make it easier for you to
write human-readable code, but it all compiles into the same machine
instructions at the end of the day.
name of every file of folder "Documents" of home of app "Finder"
app "Finder"'s home's folder "Documents"'s files's name
app('Finder.app').home.folders['Documents'].files.name # (Python)
all generate the same object specifier (to paraphrase):
[
'prop', 'prop', 'name', [
'file', 'indx', 'all ', [
'fold', 'name', 'Documents', [
'prop', 'prop', 'home', None
]]]
The other greatest feature is 'whose' clauses.
[...]
As we discussed a week or so ago, 'contains' properly requires the same
class on either side of it [...]:
{"a', "b", "c"} contains "b"
--> true
(first person whose value of every email contains {"email@hidden"})
That's really how it should work, but it errors.
.
Have to disagree: while you may argue this is an example of poor
design, both these statements _are_ working as designed.
The problem for AppleScript users is that both expressions employ the
same keyword, 'contains', but the AppleScript compiler actually
compiles this keyword to _different_ machine instructions depending
on its context (in this case, whether or not the expression follows a
'whose' keyword). The first compiles to an AppleScript language
instruction, while the second produces an Apple Event Manager
instruction.
AppleScript is riddled with these sorts of homonyms, unfortunately.
(For example, count the number of ways different meanings the 'file'
keyword can have, depending on context, relative position, time of
day, the weather we're having, etc, etc, etc.) One of its more
serious flaws, and probably not fixable short of a major - and
backwards-incompatible - redesign/rewrite (not a worthwhile exercise).
(Incidentally, this and other AppleScript language woes are also
notably absent in the MacPython-to-AEM bridge I'm working on. Though
you still have to deal with the many delightful vagaries of
individual application scripting interfaces, of course.:p)
HTH
has
--
http://freespace.virgin.net/hamish.sanderson/
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.