On 20 Jun 2014, at 2:36 am, Nigel Garvey <email@hidden> wrote:
one side-effect of what integration there is with vanilla is there's now yet another handler definition syntax which works in vanilla and which I've seen used a couple of times in vanilla scripts. I haven't yet decided whether I think this is a useful thing or a potential cause of confusion. The so-called interleaved syntax was presumably introduced for ASObjC, but there's only one AppleScript compiler, so all AppleScript uses it. However, it only appears in some contexts, so a lot of people might not see it.
Basically, if you type:
on one_two_(x, y)
it compiles in 10.9 as:
The number of underscores must match the number of arguments, and the last one must appear immediately before the parentheses, for this to happen.
But you can still call the handler the same way:
The interleaved syntax only appears if there's either a direct target, such as:
or if it's preceded by a possessive:
set x to its one:a two:b y's one:a two:b
The code compiles the same, so if you use the interleaved syntax and open the script under a version of the OS pre-Mavericks, it opens using underscores.
The downside is that it can make terminology conflicts more common, and it can require parentheses around arguments when they're not a single word.
I confess I like it, with caveats: I wish it happened all the time, and I wish the syntax coloring was different. I reckon this:
not only encourages helpful naming conventions, but is also more readable, especially when there are multiple arguments. And if you wish, you can do things like:
tell y to one:x ¬ two:y ¬ three:z
(Disclaimer: the examples with the different coloring are from my own app, which overrides the default styling.)
But knowing when the new syntax will be used means it's pretty easy to avoid if you don't like it. |