caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Pierre Weis <pierre.weis@inria.fr>
To: mvanier@cs.caltech.edu (Michael Vanier)
Cc: pierre.weis@inria.fr, caml-list@inria.fr
Subject: Re: [Caml-list] simple typing question
Date: Tue, 2 Jul 2002 16:56:22 +0200 (MET DST)	[thread overview]
Message-ID: <200207021456.QAA23642@pauillac.inria.fr> (raw)
In-Reply-To: <200207020949.g629nQ606959@orchestra.cs.caltech.edu> from Michael Vanier at "Jul 2, 102 02:49:26 am"

[...]
> I *almost* understand.  I understand the need for restrictions with
> polymorphic references.  The stated rule is that for
> 
>   let name = expr1 ...
> 
>   The type of expr1 is generalized when expr1 is a function, an identifier
>   or a constant. Otherwise the identifier name is not polymorphic (type
>   variables are not generalized).
> 
> And later it's stated that when expr1 is "map (function x -> x)" it's an
> application, so it isn't generalized.  However, it's an application that
> evaluates to a function, so it seems like it would meet the stated
> criteria.

No, it does not meet the criterium, since this criterium is ``expr1 is
a function, an identifier, or a constant'', which is evidently
syntactical in nature. Note that the words are ``expr1 is'', not
``expr1 seems to be'', ``expr1 could be considered as'', ``expr1 has a
type that is'', or whatever; hence, the criterium is NOT ``when expr1
EVALUATES to a function, an identifier, or a constant''; it could not
be since this modified rule would have no meaning at all (just
consider that no Caml expression can evaluate to an identifier, and
that all Caml expressions evaluate to constants or functions!).

Furthermore, the FAQ explicitely states afterwards that
"map (function x -> x)" is not a function, but an application!

>  Also, I'm not sure why such a restrictive rule is needed.  If
> expr1 doesn't manipulate references, why can't it be generalized?  Sorry to
> belabor this.

You are perfectly right. This rule is not needed.

More generally, you may find a lot of cases where an expression is not
generalized when it could be: you just discovered that the Caml type
system has some limitations. Hence, it is an interesting research
topic to overcome these limitations. In particular, we would be very
interesting at learning a more lenient typing discipline for
references (and more generally mutable values), if you could find a
new one that avoids the need for the drastic restriction we are now
using. It is an interesting (but extremely difficult) subject to look
at.

For a deeper discussion about the necessity for a special rule for let
in presence of mutable values, see for instance:

http://pauillac.inria.fr/~xleroy/publi/polymorphic-assignment.dvi.gz

The paper is rather old and the proposed solution has been abandoned,
but the examples given there, and the discussion about polymorphic
typing of mutable values are still inspiring, I think.

Best regards,

Pierre Weis

INRIA, Projet Cristal, Pierre.Weis@inria.fr, http://pauillac.inria.fr/~weis/


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


      parent reply	other threads:[~2002-07-02 14:56 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-07-02  4:14 Michael Vanier
2002-07-02  9:14 ` Pierre Weis
2002-07-02  9:49   ` Michael Vanier
2002-07-02 11:29     ` Daniel de Rauglaudre
2002-07-02 11:42     ` Xavier Leroy
2002-07-02 18:57       ` Pixel
2002-07-02 20:59         ` Pierre Weis
2002-07-03  0:39           ` Pixel
2002-07-03  1:49             ` Jacques Garrigue
2002-07-03 23:24               ` Pixel
2002-07-03  7:51             ` Francois Pottier
2002-07-03 11:25               ` Pixel
2002-07-03 18:10       ` Lauri Alanko
2002-07-02 14:56     ` Pierre Weis [this message]

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=200207021456.QAA23642@pauillac.inria.fr \
    --to=pierre.weis@inria.fr \
    --cc=caml-list@inria.fr \
    --cc=mvanier@cs.caltech.edu \
    /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).