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
Labels and polymorphism
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2007-03-20 (00:51)
From: Jacques Garrigue <garrigue@m...>
Subject: Re: [Caml-list] Labels and polymorphism
From: "Nathaniel Gray" <n8gray@gmail.com>

> > The second problem is more fundamental: adding labels to a function
> > cannot be done without breaking compatibility. This is because
> > labels must match exactly when you pass a function as argument to
> > another function.
> I'm not sure I accept this.  What I would like is a subtyping relation
> between labeled and unlabeled functions.  A function with labels is a
> subtype of the label-erased (or partially label-erased) version of
> that function.  Is there some reason this is not possible?

Just that subtyping doesn't play well with type inference.
This is why subtyping for objects is completely explicit.
As a result, while your subtyping-based approach seems sound, it
would still not allow transparent addition of labels, as one would
have to add coercions to "remove" labels from function types.

Note also that your subtyping approach is weaker than your earlier
proposal: out-of-order application is only allowed when all formal
parameters are labeled. And this doesn't take optional arguments into
account.  This said, this could be a nice proposal for labeled
arguments in Java, for instance.

Jacques Garrigue