English version
Accueil     À propos     Téléchargement     Ressources     Contactez-nous    

Ce site est rarement mis à jour. Pour les informations les plus récentes, rendez-vous sur le nouveau site OCaml à l'adresse ocaml.org.

Browse thread
[Caml-list] Total application of function with labels
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2004-05-05 (23:16)
From: Evan Martin <martine@d...>
Subject: Re: [Caml-list] Total application of function with labels
On Wed, May 05, 2004 at 05:18:22PM -0400, Manos Renieris wrote:
> Is there a programming convention that would "enforce" labeling the 
> arguments in a total application of a certain function? 

# type withlabels = WithLabels;;
type withlabels = WithLabels
# let withlabels = WithLabels;; 
val withlabels : withlabels = WithLabels

# let f ~a ~b ?(withlabels : withlabels option) = a + b;;
Warning: This optional argument cannot be erased
val f : a:int -> b:int -> ?withlabels:withlabels -> int = <fun>
# f 2 3 ~withlabels;;
Expecting function has type a:int -> b:int -> int
This argument cannot be applied without label

This includes the ... includes the "optional argument cannot be erased
warning", which can be avoided at the cost of making the code even

discusses this a bit, but I'm not quite sure I understand it.  :\

Evan Martin

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