Re: wishlist: user-declared parameter labels without "given"
Re: wishlist: user-declared parameter labels without "given"
- Subject: Re: wishlist: user-declared parameter labels without "given"
- From: "Arthur J Knapp" <email@hidden>
- Date: Sun, 01 Apr 2001 17:54:12 -0400
>
Date: Sun, 01 Apr 2001 17:37:37 +1000
>
Subject: Re: wishlist: user-declared parameter labels without "given"
>
From: Timothy Bates <email@hidden>
>
On 4/1/01 10:08 AM, "Arthur J Knapp" <email@hidden> wrote:
>
> The compromise might be to write your handlers to take a single
>
> record as a parameter:
>
>
>
> getasample( { taking: 3, from_list: {1, 2, 3, 4}, replacing: false } )
>
What a brilliant idea! I will give it a try.
One of the nice things about using a record in this way is that
you can essentially make use of optional parameters, (something
that AppleScript does not support).
on makeCar( wheels_color_model )
set theDefault to { wheels:"white-wall", color:"Red", model:"Honda" }
-- Record Concatenation
--
-- User-defined labels will override the theDefault, and labels
-- not defined by the user will come from the theDefault
--
set theParameters to wheels_color_model & theDefault
set str to "My car wheels are " & wheels of theParameters & ".\r"
set str to str & "My car's color is " & color of theParameters & ".\r"
set str to str & "My car's model is " & model of theParameters & ".\r"
return str
end makeCar
makeCar({})
(*
"My car wheels are white-wall.
My car's color is Red.
My car's model is Honda.
"
*)
makeCar( { wheels:"Firestone", model:"Aston Martin" } )
(*
"My car wheels are Firestone.
My car's color is Red.
My car's model is Aston Martin.
"
*)
Arthur J. Knapp
http://www.stellarvisions.com
mailto:email@hidden
Hey, check out:
http://MacScripter.net/