On 20 Jun 2016, at 3:49 AM, Jim Underwood <email@hidden> wrote:
Is it better to use tell sortLib to quickSort(resultsList)
Than quickSort(resultsList) of sortLib Or sortLib's quickSort(resultsList)
Or, are all 3 equally recommended? Does it just come down to personal preference?
It's a matter of personal preference in a simple case like that. But that's not the case if you use interleaved syntax in your handlers. And let me make the case for considering the use of interleaved handlers.
Consider this statement:
display dialog "Enter your name" default answer myName buttons {"Cancel", "OK"} default button 2 giving up after 30
Now imagine if the syntax was this:
display dialog default answer buttons default button giving up after ("Enter your name", myName, {"Cancel", "OK"}, 2, 30)
You'd probably say that's crazy. Yet people continue writing handlers that way, because that's the way they've always done it.
So consider a simple example:
on doSandR(theFind, theReplace, theText, matchCaseFlag)
It's simple enough to use, and the variable names give you a clue. But when you see it used in code, you might see something like this:
my doSandR(theModel, theName, theBody, true)
Unless you use it a lot, or look up the definition -- which might be in another file if it's in a library -- you're guessing what's what. You could make it better like this:
my findReplaceInMatchingCase(theModel, theName, theBody, true)
But it's still an effort to understand.
Here's an interleaved equivalent:
on findText:theFind inText:theText replaceItWith:theReplace matchingCase:matchCaseFlag
And when you see that called in code, there's no reliance on variable names or order to understand what the parameters are. Apart from the colons, it's much closer to standard AppleScript commands.
But there's a catch, which comes back to your question. For interleaved syntax to compile, it needs to follow a possessive. So you need to precede it with an otherwise superfluous "its", or you need to use the third of your options.
And there's one other wrinkle to your question. If the target is a Cocoa class, putting it first means editors like Script Debugger 6 (and ASObjC Explorer) can take advantage of that in code completion, and offer you only choices that are valid for that class.
You did ask...
|