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] labels and optional arguments in 3.06
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2002-11-14 (03:35)
From: Jacques Garrigue <garrigue@k...>
Subject: Re: [Caml-list] labels and optional arguments in 3.06
From: Chris Hecker <checker@d6.com>
> >val f : ~a:float -> ?a:float -> float -> float
> Why would this even be legal?  Is there some reason to allow multiple 
> labels with the same name?

There is a good reason to have it legal: there is no way to make it

Suppose you have a polymorphic function:
val g : f:'a -> a:int -> 'a
# g ~f:(fun ~a -> not a);;
- : a:int -> a:bool -> bool

As long as we use normal type variables for function results, we must
allow it.

> Is there a problem with the behavior I want without duplicate labels?

Indeed, that would leave no ambiguity. So it might be ok to allow
mixing labelled optional arguments in an otherwise unlabelled
application, if there is no ambiguity on labels. But is it really
worth a strange definition, when the workaround is just to add

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