caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* [Caml-list] labels and optional arguments in 3.06
@ 2002-11-13 23:33 Chris Hecker
  2002-11-14  1:05 ` Jacques Garrigue
  0 siblings, 1 reply; 10+ messages in thread
From: Chris Hecker @ 2002-11-13 23:33 UTC (permalink / raw)
  To: caml-list


The new optional label semantics seem to work pretty well for my
normal usage, however I've run across one thing I'd like to do that
doesn't seem to work (and a warning I don't understand):

> # let f ?(a = 1.0) ~b ~c = a *. b *. c;;
> Characters 12-15:
> Warning: This optional argument cannot be erased
>   let f ?(a = 1.0) ~b ~c = a *. b *. c;;
>               ^^^
> val f : ?a:float -> b:float -> c:float -> float = <fun>

First question:  what is this warning?

Second question:  I'd like to be able to call f with or without
specifying the optional argument, without labels:

> # f;;
> - : ?a:float -> b:float -> c:float -> float = <fun>
> # f 2.0 4.0;;
> - : float = 8.

works fine,

> # f ~a:2.0 2.0 4.0;;
> Characters 9-12:
>   f ~a:2.0 2.0 4.0;;
>            ^^^
> Expecting function has type b:float -> c:float -> float
> This argument cannot be applied without label

doesn't work.  I'd like to be able to use ~b and ~c for interface
documentation, but not be forced to use them, and have ?a be an
optional parameter.  This

> # f ~a:2.0 ~b:2.0 ~c:4.0;;
> - : float = 16.

works, of course, but it's really verbose.

Is there any way to make this work?

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


^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2002-11-15  2:22 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-11-13 23:33 [Caml-list] labels and optional arguments in 3.06 Chris Hecker
2002-11-14  1:05 ` Jacques Garrigue
2002-11-14  2:45   ` Chris Hecker
2002-11-14  3:34     ` Jacques Garrigue
2002-11-14  4:57       ` Chris Hecker
2002-11-14  8:23         ` Jacques Garrigue
2002-11-14 18:31           ` Chris Hecker
2002-11-15  1:09             ` Jacques Garrigue
2002-11-15  2:21               ` Chris Hecker
2002-11-14  7:40   ` Alessandro Baretta

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).