• 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
Variable parameter lists and more! (was Re: wishlist: user-declared parameter labels without "given"
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Variable parameter lists and more! (was Re: wishlist: user-declared parameter labels without "given"


  • Subject: Variable parameter lists and more! (was Re: wishlist: user-declared parameter labels without "given"
  • From: Timothy Bates <email@hidden>
  • Date: Mon, 02 Apr 2001 12:08:18 +1000

> On 4/1/01 10:08 AM, "Arthur J Knapp" <email@hidden> wrote:
>> you can write your handlers to take a record as a parameter:
>> getasample( { taking: 3, from_list: {1, 2, 3, 4}, replacing: false } )

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.

icanhandleanyorder({x:"x", z:"z", y:"y"})

on icanhandleanyorder({x:x, y:y, z:z})
display dialog "x is" & x & ", y is" & y & ", z is" & z
end icanhandleanyorder

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.

so you can say

do1ofseveralthings({task:"beep", parameters:{}})
do1ofseveralthings({task:"add", parameters:{2, 2}})

on do1ofseveralthings({task:task, parameters:parameters})
if task is "beep" then
beep
else if task is "add" then
display dialog (item 1 of parameters) + (item 2 of parameters)
end if
end do1ofseveralthings

Rock on! that is so powerful.

tim


  • Follow-Ups:
    • Re: Variable parameter lists and more! (was Re: wishlist: user-declared parameter labels without "given"
      • From: Paul Berkowitz <email@hidden>
    • Re: Variable parameter lists and more! (was Re: wishlist: user-declared parameter labels without "given"
      • From: Paul Berkowitz <email@hidden>
References: 
 >Re: wishlist: user-declared parameter labels without "given" (From: Timothy Bates <email@hidden>)

  • Prev by Date: Re: [Admin?]
  • Next by Date: Re: List within a List
  • Previous by thread: Re: wishlist: user-declared parameter labels without "given"
  • Next by thread: Re: Variable parameter lists and more! (was Re: wishlist: user-declared parameter labels without "given"
  • Index(es):
    • Date
    • Thread