About the use statement
About the use statement
- Subject: About the use statement
- From: Axel Luttgens <email@hidden>
- Date: Sat, 04 Jun 2016 11:13:27 +0200
> Le 4 juin 2016 à 02:26, Shane Stanley a écrit :
>
> […]
>
> So all those who are confused, angry or frustrated — or even mildly surprised -- put up your hands.
As usual, the ASLG provides some clues, yet somewhat too elliptically.
Perhaps could the whole "[FYI] more sdef-based library stupidity" thread be viewed as the basis for a documentation enhancement request?
At:
https://developer.apple.com/library/mac/documentation/AppleScript/Conceptual/AppleScriptLangGuide/reference/ASLR_control_statements.html#//apple_ref/doc/uid/TP40000983-CH6g-SW4
one may read:
use statements can also import terminology from the used
resource, making the terms available throughout the script
without requiring the use of tell or using terms from.
AppleScript tracks where terms were imported from, and sends
events that use those terms to that target. Ordinarily,
commands are sent to the current target (it) as described in
Target, but imported terminology overrides this. If…
• the event identifier is imported
• the direct parameter is an imported class or
enumeration identifier
• the direct parameter is an object specifier ending
with an imported term
…then the command is sent to the import source instead. This
happens even if the command is inside a tell block for a
different target.
It is rather difficult to tell, from the above, the exact decision tree (does one of the conditions prevail? does the description imply some ordering? is the description a complete one?).
Anyway, this may help to explain why this early example:
use application "Finder"
reveal someLocalHandler()
on someLocalHandler()
return "/" as POSIX file
end someLocalHandler
yields:
tell application "Finder"
someLocalHandler()
—> error number -1708
According to the above excerpt, there’s only one piece to care about here, an "imported event specifier" (the one corresponding for the Finder’s command "reveal"); the whole command is thus sent to the "import source" (the Finder).
But then, what about this one:
use application "Finder"
use application "System Events"
reveal file packages
which sends the event to System Events:
tell application "System Events"
«event miscmvis» every file package
Unless im wrong, there is an "imported event specifier" and an "object specifier ending with an imported term". But, from the above ASLG excerpt alone, I would have been unable to predict the outcome (hence my hands put up).
It would probably be worth to have a better description at hand, so that the intents is clearly and completely spelled out.
After that, it would be possible to discuss the pro and the cons of the current implementation around that use statement.
Axel
_______________________________________________
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