• 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: wishlist: user-declared parameter labels without "given"
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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/


  • Follow-Ups:
    • Re: wishlist: user-declared parameter labels without "given"
      • From: Paul Berkowitz <email@hidden>
  • Prev by Date: Re: bugs, bugs, bugs
  • Next by Date: Re: wishlist: user-declared parameter labels without "given"
  • Previous by thread: wishlist: user-declared parameter labels without "given"
  • Next by thread: Re: wishlist: user-declared parameter labels without "given"
  • Index(es):
    • Date
    • Thread