From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from majordomo@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id CAA26606; Fri, 28 Mar 2003 02:33:06 +0100 (MET) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id CAA27194 for ; Fri, 28 Mar 2003 02:33:05 +0100 (MET) Received: from mail2.hypermall.com (mail2.hypermall.com [216.241.37.118]) by concorde.inria.fr (8.11.1/8.11.1) with ESMTP id h2S1X4518920 for ; Fri, 28 Mar 2003 02:33:04 +0100 (MET) Message-Id: <200303280133.h2S1X4518920@concorde.inria.fr> Received: from [216.241.35.41] (helo=swordfish) by mail2.hypermall.com with esmtp (Exim 3.36 #1) id 18yijv-0000Xa-00 for caml-list@pauillac.inria.fr; Thu, 27 Mar 2003 18:33:03 -0700 X-cs: R From: Matt Gushee X-RS-ID: X-RS-Flags: 0,0,1,1,0,0,0 X-RS-Header: In-reply-to: <4.3.2.7.2.20030327170154.04599ef8@localhost> X-RS-Sigset: -1 To: Chris Hecker Subject: Re: [Caml-list] naming parts of optional arguments? MIME-Version: 1.0 Content-type: text/plain; charset=ISO-8859-1 Content-transfer-encoding: 8BIT Date: Thu, 27 Mar 2003 18:32:27 -0700 X-Spam: no; 0.00; gushee:01 mgushee:01 havenrock:01 caml-list:01 hecker:01 val:01 0.0,:01 0.0:01 floats:01 englewood:01 chris:01 05,:01 float:02 unit:03 wrote:03 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk On 27 Mar 2003 at 17:05, Chris Hecker wrote: > Is there a way to name the components of an optional argument? Are you sure that's what you need to do? Your examples don't show you using the x and y values separately. > # let f ((x,y) as xy) = xy;; > val f : 'a * 'b -> 'a * 'b = > # let f ?xy () = xy;; > val f : ?xy:'a -> unit -> 'a option = > # let f ?((x,y) as xy) () = xy;; > Characters 8-9: > let f ?((x,y) as xy) () = xy;; At any rate, this works for me: # let f ?(xy = 0.0, 0.0) () = xy;; val f : ?xy:float * float -> unit -> float * float = Now you know xy is a pair of floats, and it's simple to extract the separate values if you need to. Or do you need something else that I've missed? -- Matt Gushee Englewood, CO USA ------------------- To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/ Beginner's list: http://groups.yahoo.com/group/ocaml_beginners