caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Jacques Garrigue <garrigue@kurims.kyoto-u.ac.jp>
To: remy@morgon.inria.fr
Cc: caml-list@inria.fr
Subject: Re: [Caml-list] Future of labels, and ideas for library labelling
Date: Thu, 12 Apr 2001 00:11:14 +0900	[thread overview]
Message-ID: <20010412001114U.garrigue@kurims.kyoto-u.ac.jp> (raw)
In-Reply-To: <m38y9t7a867.fsf@morgon.inria.fr>

Salut Didier,

> I am not sure I understand all your conclusions: 
> 
> > * SLIGHTLY extend it to allow non-labelled complete applications of
> >   functions: this is non-ambiguous, but keep a warning for PURISTS,
> >   and also because of the SLIGHT MISMATCH between PROGRAM TEXT and
> >   UNTYPED SEMANTICS
> 
> I do not understand much of this sentence. 
> Moreover, I am a bit worried by  the use of the words I've emphasized.

Yes, this is not the kind of language you usually understand. I think I
gave a bit more details on it in the developper's list, but anyway
here are full details for interested people.

The intended "slight" extension:

Suppose I have a function f, of type string -> pos:int -> len:int ->
string. It appears in a program applied on 3 arguments, without any
labels:
        f "Hello" 1 2
The idea is to have the type checker insert the labels rather than
fail with a type error.
To be sure nothing ambiguous is happening, and to avoid "misuses" of
this feature, we have to be a bit strict:
* no argument should be labelled
* the arity of f must be known, and it must exactly match the number
  of arguments
In particular functions whose return type is a type variable are not
eligible for that, since their arity is unknown.

With all these conditions, it is clear that no ambiguity will happen:
type checking was going to fail otherwise, and there is only one way
to add labels in this application.
If you care about stronger properties than that, in the current
version type checking with labels is not complete, but it produces a
unique type: when type checking succeeds, the type it finds does not
depend on the inference algorithm, but whether a type will be found or
not depends on it. Basically this property is not changed: either we
knew the complete type for f at the application point, and could add the
right labels, or we didn't know the type and it will fail either
immediately or later.
By the way, we were doing something pretty similar in our paper on
first class polymorphism.

The problem I describe at the semantics level is related to this
notion of adding labels. Without optional arguments, the reduction in
label mode can be described by this single rule:
 (fun ~ln:x -> e) ~l1:v1 ... ~ln:vn ---> e[vn/x] ~l1:v1 ... ~ln-1:vn-1
No label is just the empty label, behaving exactly like other labels.

If we try to apply a labelled function to unlabelled arguments (with
empty labels), reduction will be stuck. So this idea of "adding
labels" during type checking, which results in this "slight" gap
between the program and its untyped semantics: there is no ambiguity,
but the program you reduce is not exactly the one you wrote (which
would have been stuck anyway). So the warning is both for semantics
purists, who want to be sure they can apply semantic rules directly on
their source code, and label purists, who do not want to omit labels
anyway.

I suppose there are other ways to handle this, by extending a bit the
semantics, but you would still need some kind of non-syntactic
information, like the arity of f.

> > * put some labels in alternative versions of a few libraries
> >   (List, Array, Unix). Access to these libraries would use already
> >   existing ways: "open Stdlabels", "module Unix = Lunix"
> > * also add alternative labelled versions for the few functions with
> >   more than 4 arguments in the standard library (e.g. String.blit')
> 
> Since these two points are the same, that is, provide alternative labeled
> versions of some functions, could they be solved in the same way (introduce
> a prime version of module M v.s. introduction primed definitions of
> identifier f), so as to avoid dupplicating conventions.
> 
> Also, before you chose names for the primed modules, can you find a uniform
> convention (c.f. Stdlabels and Lunix that you keep using in examples).  Or,
> could these modules have the same name but be defined in a subdirectory of
> the stdlib?

I do not expect many of them, and I'm not even sure users will want to
use labels everywhere simultaneously: labellings in List and Unix are
rather different in nature. So they could happily stay in the main
directory. Also having primes in module names may be problematic,
if they are to be compilation units: any idea on how various operation
systems handle primes in file names?

I must admit I didn't seriously consider the problem of naming. We
could probably find a solution among developpers. And a prerequisite
is of course that this proposal (or a variant of it) gets accepted,
which is not clear yet.

Best regards,

Jacques
-------------------
To unsubscribe, mail caml-list-request@inria.fr.  Archives: http://caml.inria.fr


  reply	other threads:[~2001-04-11 15:12 UTC|newest]

Thread overview: 76+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-03-31  3:40 [Caml-list] Future of labels Yaron M. Minsky
2001-04-02  3:39 ` [Caml-list] Future of labels, and ideas for library labelling Jacques Garrigue
2001-04-02  7:58   ` Judicael Courant
2001-04-02  8:50     ` Markus Mottl
2001-04-02 10:33     ` kahl
2001-04-03  0:35       ` Jacques Garrigue
2001-04-03  1:36         ` Kipton M Barros
2001-04-03  1:52         ` Patrick M Doane
2001-04-03  3:53           ` Jacques Garrigue
2001-04-03  5:10             ` Patrick M Doane
2001-04-03  9:30               ` Jacques Garrigue
2001-04-03  8:52             ` Xavier Leroy
2001-04-03  9:34               ` Judicael Courant
2001-04-03  9:54               ` Jacques Garrigue
2001-04-03 12:59                 ` Jean-Christophe Filliatre
2001-04-03 13:11                   ` [Caml-list] ocaml, java, rmi and jini Martin Berger
2001-04-03 19:23                     ` Chris Hecker
2001-04-03 20:50                       ` Gerd Stolpmann
2001-04-06  9:40                         ` Sven LUTHER
2001-04-06 20:57                           ` Gerd Stolpmann
2001-04-03 21:06                       ` martinb
2001-04-06 15:03                     ` Xavier Leroy
2001-04-03 14:06                   ` [Caml-list] Future of labels, and ideas for library labelling Jacques Garrigue
2001-04-03 14:12                     ` Daniel de Rauglaudre
2001-04-03 14:42                       ` Claude Marche
2001-04-04 19:18                     ` Gerd Stolpmann
2001-04-03  9:55               ` Ohad Rodeh
2001-04-03 18:06                 ` [Caml-list] Example of Ocaml-syntax problem with ; Mattias Waldau
2001-04-04 15:15                 ` [Caml-list] Suspending threads Ohad Rodeh
2001-04-04 17:28                   ` Vitaly Lugovsky
2001-04-06 13:21                   ` Xavier Leroy
2001-04-03 12:02               ` [Caml-list] Future of labels, and ideas for library labelling Dave Mason
2001-04-03 13:43               ` Francois-Rene Rideau
2001-04-03 14:23                 ` Daniel de Rauglaudre
2001-04-03 13:43               ` Frank Atanassow
2001-04-03 13:58               ` Joshua D. Guttman
2001-04-03 16:52               ` Eric C. Cooper
2001-04-09  9:05                 ` John Max Skaller
2001-04-09  7:29             ` John Max Skaller
2001-04-03  8:07         ` Judicael Courant
2001-04-03  6:55     ` Chris Hecker
2001-04-03 18:13       ` [Caml-list] Generics? Brian Rogoff
2001-04-03 20:12         ` Chris Hecker
2001-04-10 16:48           ` John Max Skaller
2001-04-09  8:11       ` [Caml-list] Future of labels, and ideas for library labelling John Max Skaller
2001-04-09  9:21         ` Jacques Garrigue
2001-04-09 15:06           ` Fergus Henderson
2001-04-10 18:49           ` John Max Skaller
2001-04-09 19:54         ` Chris Hecker
2001-04-10  3:37           ` Jacques Garrigue
2001-04-10  7:42             ` Judicael Courant
2001-04-10  8:25               ` Jacques Garrigue
2001-04-10  8:46               ` Claude Marche
2001-04-10 10:09                 ` Jacques Garrigue
2001-04-10 14:42                   ` Lionnel Maugis
2001-04-10  9:06             ` François-René Rideau
2001-04-11 15:34               ` Jacques Garrigue
2001-04-11 17:48                 ` Dave Mason
2001-04-12 12:39                 ` [Caml-list] How do I define prog1? Mattias Waldau
2001-04-12 14:22                   ` Vitaly Lugovsky
2001-04-12 17:53                     ` William Chesters
2001-04-12 15:15                   ` Sven LUTHER
2001-04-12 16:14                     ` Mattias Waldau
2001-04-12 15:21                   ` Maxence Guesdon
2001-04-12 15:47                   ` Stefan Monnier
2001-04-17 20:04                     ` Chris Hecker
2001-04-10 22:43             ` [Caml-list] Future of labels, and ideas for library labelling Brian Rogoff
2001-04-11  8:29               ` Jacques Garrigue
2001-04-11  9:44                 ` Anton Moscal
2001-04-11 13:16                 ` Didier Remy
2001-04-11 15:11                   ` Jacques Garrigue [this message]
2001-04-03  7:27 Arturo Borquez
2001-04-03 16:39 John R Harrison
2001-04-04 16:37 Dave Berry
2001-04-11 10:48 Francois-Rene Rideau
2001-04-17 11:53 Poigné

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20010412001114U.garrigue@kurims.kyoto-u.ac.jp \
    --to=garrigue@kurims.kyoto-u.ac.jp \
    --cc=caml-list@inria.fr \
    --cc=remy@morgon.inria.fr \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).