From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from weis@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id RAA16472 for caml-redistribution; Mon, 9 Feb 1998 17:07:20 +0100 (MET) Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id OAA13338 for ; Mon, 9 Feb 1998 14:25:26 +0100 (MET) Received: from macon.informatik.uni-tuebingen.de (macon2.Informatik.Uni-Tuebingen.De [134.2.13.2]) by nez-perce.inria.fr (8.8.7/8.8.5) with ESMTP id OAA07545 for ; Mon, 9 Feb 1998 14:25:23 +0100 (MET) Received: from marvin.informatik.uni-tuebingen.de (marvin.Informatik.Uni-Tuebingen.De [134.2.12.11]) by macon.informatik.uni-tuebingen.de (8.8.4/8.8.3/AIX-4.1/WSI-1.0) with SMTP id OAA14518; Mon, 9 Feb 1998 14:25:21 +0100 Received: from localhost by marvin.informatik.uni-tuebingen.de (AIX 4.1/UCB 5.64/4.03) id AA19526; Mon, 9 Feb 1998 14:25:19 +0100 Date: Mon, 9 Feb 1998 14:25:19 +0100 (MET) From: Simon Helsen X-Sender: helsen@marvin To: Moreau Cc: Caml list Subject: Re: Re : Weak types ? In-Reply-To: <01bd3330$064565a0$739536c1@pluton.ac.grenoble.fr> Message-Id: Mime-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: weis > 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