Version française
Home     About     Download     Resources     Contact us    
Browse thread
[Caml-list] naming parts of optional arguments?
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Chris Hecker <checker@d...>
Subject: Re: [Caml-list] naming parts of optional arguments?

[old thread resurrected]

Actually, I spoke too soon below, you have to have the "as xy" on there to 
be able to reference the tuple by xy.  Doesn't that seem redundant given 
the ?xy: specification (which doesn't seem to be used)?

# let f ?xy:((x,y)=(0,0)) () = x + y;;
val f : ?xy:int * int -> unit -> int = <fun>
# let f ?xy:((x,y)=(0,0)) () = xy;;
Characters 29-31:
   let f ?xy:((x,y)=(0,0)) () = xy;;
                                ^^
Unbound value xy
# let f ?xy:((x,y) as xy =(0,0)) () = xy;;
val f : ?xy:int * int -> unit -> int * int = <fun>
# let f ?xy:((x,y) as blah =(0,0)) () = blah;;
val f : ?xy:int * int -> unit -> int * int = <fun>
#

Chris



At 18:11 3/27/2003 -0800, Chris Hecker wrote:

>James replied off list, but I thought the others might like to see it:
>
>At 17:35 3/27/2003 -0800, james woodyatt wrote:
>># let f ?xy:(x,y as xy = 0.0,0.0) () = xy;;
>>val f : ?xy:float * float -> unit -> float * float = <fun>
>
>Ah, that's what I wanted, thanks!  It looks like you can just do ?xy:(x,y 
>= 0,0) and skip the "as xy" too.  Wacky syntax...it looks like I should 
>have looked in the pseudo-bnf before posting since it looks like this is 
>in there.
>
>Thanks,
>Chris
>
>
>-------------------
>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

-------------------
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