• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: calling handler with named parameters fails from script?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: calling handler with named parameters fails from script?


  • Subject: Re: calling handler with named parameters fails from script?
  • From: email@hidden
  • Date: Sat, 31 Mar 2001 23:00:23 -0500

On Sun, 01 Apr 2001 03:38:07 +1000, Timothy Bates <email@hidden> asked,

> Any clue as to why these first two forms fail to compile:
>
> set newList to bob's getASample of 2 from {1,2,3} without Replacement
> set newList to getASample of 2 from {1,2,3} without Replacement of bob
>
> but this succeeds?
>
> tell bob
> set sampledList to getASample of 2 from {1,2,3} without Replacement
> end tell
>

The problem is that the use of "of" to mean "direct parameter" and "of" mean
"owning object" causes ambiguities. For that reason, I usually don't use direct
parameters in my handlers, although I am a big fan of named parameters.

And I echo Dr. Bate's complaints (in his subsequent message 'wishlist:
user-declared parameter labels without "given"') about the limited number of
names available. I wouldn't go so far as to expect any number of words or
phrases to be available to the scripter (I know this ability is available to
Scripting Additions, but its hard to *define* the handler in AppleScript in a
compact way that calls out what parameter names are being defined.). My biggest
complaint is that language doesn't allow the direct parameter to be invoked
without the "of", which really interferes with writing English-like handler
calls. I'd love to call one of my handlers like,

remove "Dog" from myAnimals

but I'm stuck with

remove of "Dog" from myAnimals

and I can't package that in a script object without the overloading of "of"
causing trouble. So I get by with

tell DoggeralCatcher to removal for "Dog" from myAnimals

(Usually, I get in trouble by thinking of the objects of my "verbs" (handlers)
as things to be manipulated, when I really need to keep handlers as "pure"
functions, without side effects. Because if you want a handler to manipulate a
parameter, you have to say,

remove of "Dog" from a reference to myAnimals

I think the problem would be best solved by being more object-oriented, and
having the object do the verb, rather than having the verb work on the object.
That is,

tell myAnimals to remove("Dog")

But I won't complain too loudly. These aspect of the AppleScript language look
like they are set in stone. Defining new words and new functionality for words
is doable, but changing how the AppleScript compiler interprets these words and
perhaps changing the underlying tokens of the language would be quite difficult.
I'd rather have a whole list of things in the language instead of improving
this little blemish.

But maybe, just maybe, if the handler were defined as,

on hname given param1:val1, param2:val2, param3:val3

it would be callable as

hname param1 arg1 param2 arg2 param3 arg3

--
Scott Norton Phone: +1-703-299-1656
DTI Associates, Inc. Fax: +1-703-706-0476
2920 South Glebe Road Internet: email@hidden
Arlington, VA 22206-2768 or email@hidden


  • Prev by Date: Re: bugs, bugs, bugs
  • Next by Date: Re: Default Folder (was Re: bugs, bugs, bugs)
  • Previous by thread: When did Remote Access Commands get depreciated?
  • Next by thread: Re: Where am I?
  • Index(es):
    • Date
    • Thread