From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.1.3 (2006-06-01) on yquem.inria.fr X-Spam-Level: X-Spam-Status: No, score=1.0 required=5.0 tests=AWL,SPF_NEUTRAL autolearn=disabled version=3.1.3 X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by yquem.inria.fr (Postfix) with ESMTP id 16559BC6B for ; Wed, 27 Jun 2007 14:00:59 +0200 (CEST) Received: from mx1.polytechnique.org (mx1.polytechnique.org [129.104.30.34]) by concorde.inria.fr (8.13.6/8.13.6) with ESMTP id l5RC0wZO031137 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=FAIL) for ; Wed, 27 Jun 2007 14:00:58 +0200 Received: from localhost (is005115.intra.cea.fr [132.166.135.75]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by ssl.polytechnique.org (Postfix) with ESMTP id 1F2C133191 for ; Wed, 27 Jun 2007 14:00:55 +0200 (CEST) Date: Wed, 27 Jun 2007 14:00:54 +0200 From: Virgile Prevosto To: caml-list@yquem.inria.fr Subject: Re: [Caml-list] let rec and polymorphic functions Message-ID: <20070627140054.68bec31a@localhost> In-Reply-To: <46824622.2080508@ed.ac.uk> References: <20070627100004.9E0DABC73@yquem.inria.fr> <001801c7b8a5$672a2b80$6a7ba8c0@treble> <46824622.2080508@ed.ac.uk> X-Mailer: Sylpheed-Claws 2.6.0 (GTK+ 2.10.11; i486-pc-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-AV-Checked: ClamAV using ClamSMTP at djali.polytechnique.org (Wed Jun 27 14:00:55 2007 +0200 (CEST)) X-Org-Mail: virgile.prevosto.1996@polytechnique.org X-Miltered: at concorde with ID 4682517A.002 by Joe's j-chkmail (http://j-chkmail . ensmp . fr)! X-Spam: no; 0.00; recursive:01 val:01 ocaml:01 rhs:01 compiler:01 ocaml:01 inference:01 recursive:01 well-typed:01 rhs:01 foo:01 rec':01 tutto:98 oggi:98 volta:98 Le mer 27 jun 2007 12:12:34 CEST, Jeremy Yallop a =C3=A9crit : > David Allsopp wrote: > > let rec id x =3D x > > and _ =3D id 0 > > in > > id (); (* *** *) > > id 1;; > >=20 > This isn't really "the equivalent SML", since the definition of `id > x' and the application `id 0' aren't in the same recursive group. > The equivalent in SML would be something like >=20 > let val rec id =3D fn x =3D> x > and _ =3D id 0 > in > id (); > id 1 > end >=20 >=20 > OCaml seems a little inconsistent here, actually. The application > `id 0' is only valid as the rhs of let rec because the compiler can=20 Well, it just seems that Ocaml performs type inference before checking the validity of the recursive definition. If you give a well-typed term, it will complain about a forbidden rhs of let rec: Objective Caml version 3.10.0 # let rec id =3D fun x -> x and _foo =3D id 0 in id 1;; This kind of expression is not allowed as right-hand side of `let rec' --=20 E tutto per oggi, a la prossima volta. Virgile