Mailing list for all users of the OCaml language and system.
 help / color / mirror / Atom feed
From: Simon Helsen <helsen@informatik.uni-tuebingen.de>
To: Moreau <lyclaire@ac-grenoble.fr>
Cc: Caml list <caml-list@inria.fr>
Subject: Re: Re : Weak types ?
Date: Mon, 9 Feb 1998 14:25:19 +0100 (MET)	[thread overview]
Message-ID: <Pine.A32.3.96.980209141030.14334E-100000@marvin> (raw)
In-Reply-To: <01bd3330$064565a0$739536c1@pluton.ac.grenoble.fr>

> let toto y =
>  let id x = x in
> id id y ;;
> 
> this will be of type 'a ->'a
> What is the difference with this :
> 
> let toto = let id x = x in id id ;;
> 
> I thought caml will understand that there is no difference !
> 
> why does caml make this difference ?

Eta-expansion (what you're doing in the first example) indeed solves the
this common degration of polymorphic values to pseudo poly's. The
fundamental reason being the syntactic approach of value polymorhism.  The
first example is just syntactic sugar for "let toto = function y -> let id
x = x in id id y" So, toto is defined as a lambda, which is non-expansive
(and this is obvious since this type of declaration can never do something
"wrong" in the sence of polymorphic references, the actual reason value
polymorphism). However, in the 2nd example, the declaration is an
*application* (which of course results in a function, but that's
syntactically not apparent) Hence, the resulting poly value has to degrade
(to avoid potential problems with polymorphic references) 

Note that the 2nd example is again invalid Standard ML and there we rely
on eta-expansion to write something like that at all...

Hope this helps,

Simon

PS: I know people on this list are Ocaml users, but it might be worth to
look at pages 321-326 (section 8.3) of the reference below. It contains a
fairly good explanation of the problem with poly-references and value
polymorphism. It also gives a brief description of the history of this
problem:

"ML for the working programmer -2nd edition", L.C.Paulson, 1996, Cambridge
University Press






  reply	other threads:[~1998-02-09 16:07 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1998-02-06 18:49 Moreau
1998-02-09 13:25 ` Simon Helsen [this message]
1998-02-09 14:21 ` Pascal Cuoq

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=Pine.A32.3.96.980209141030.14334E-100000@marvin \
    --to=helsen@informatik.uni-tuebingen.de \
    --cc=caml-list@inria.fr \
    --cc=lyclaire@ac-grenoble.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