Re: Variable parameter lists and more! (was Re: wishlist: user-declared parameter labels without "given"
Re: Variable parameter lists and more! (was Re: wishlist: user-declared parameter labels without "given"
- Subject: Re: Variable parameter lists and more! (was Re: wishlist: user-declared parameter labels without "given"
- From: Paul Berkowitz <email@hidden>
- Date: Mon, 02 Apr 2001 02:21:05 -0700
As it's now been 8 hours since I sent this message, I'd better send it
again. I suppose the original will turn up some time within the next 36
hours. (We're not even supposed to comment any more, I think.)
On 4/1/01 7:08 PM, "Timothy Bates" <email@hidden> wrote:
>
I just found out two fantastic things:
>
>
1. If you write a handler to take a record as its input, it unpacks them
>
automagically, and doesn't care what order the items are in.
True for everything to do with records: records are not ordered. The label
provides all identification needed. This can be really useful at times.
>
2. And more fantastic: this allows us to have optional parameters (I just
>
read Paul and Arthur's mails more closely and Arthur in fact noted this
>
already.
>
<snip>
>
>
Rock on! that is so powerful.
Yup! Even:
do1ofseveralthings({task:"beep", parameters:{}})
do1ofseveralthings({task:"add", parameters:{2, 2}, aWord:"See-ee?"})
on do1ofseveralthings(anyRecord)
set thisThing to anyRecord & {aWord:"beep"}
set {task, aWord, parameters} to thisThing's {task, aWord, parameters}
if task = "beep" then
beep
else
display dialog (item 1 of parameters) + (item 2 of parameters)
end if
say aWord
end do1ofseveralthings
--
Paul Berkowitz