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=0.0 required=5.0 tests=none autolearn=disabled version=3.1.3 X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from discorde.inria.fr (discorde.inria.fr [192.93.2.38]) by yquem.inria.fr (Postfix) with ESMTP id 54748BC6B for ; Wed, 27 Jun 2007 15:05:01 +0200 (CEST) Received: from grassmarket.ucs.ed.ac.uk (grassmarket.ucs.ed.ac.uk [129.215.166.64]) by discorde.inria.fr (8.13.6/8.13.6) with ESMTP id l5RD50wI020659 for ; Wed, 27 Jun 2007 15:05:01 +0200 Received: from [129.215.11.81] (dhcp-11-81.inf.ed.ac.uk [129.215.11.81]) by grassmarket.ucs.ed.ac.uk (8.13.8/8.12.10) with ESMTP id l5RD4xPt021869; Wed, 27 Jun 2007 14:04:59 +0100 (BST) Message-ID: <46825F52.50704@ed.ac.uk> Date: Wed, 27 Jun 2007 14:00:02 +0100 From: Jeremy Yallop User-Agent: Icedove 1.5.0.10 (X11/20070329) MIME-Version: 1.0 To: Virgile Prevosto Cc: caml-list@yquem.inria.fr Subject: Re: [Caml-list] let rec and polymorphic functions References: <20070627100004.9E0DABC73@yquem.inria.fr> <001801c7b8a5$672a2b80$6a7ba8c0@treble> <46824622.2080508@ed.ac.uk> <20070627140054.68bec31a@localhost> In-Reply-To: <20070627140054.68bec31a@localhost> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Edinburgh-Scanned: at grassmarket.ucs.ed.ac.uk with MIMEDefang 2.33, Sophie, Sophos Anti-Virus X-Scanned-By: MIMEDefang 2.33 (www . roaringpenguin . com / mimedefang) X-Miltered: at discorde with ID 4682607C.003 by Joe's j-chkmail (http://j-chkmail . ensmp . fr)! X-Spam: no; 0.00; ocaml:01 rhs:01 compiler:01 ocaml:01 inference:01 recursive:01 well-typed:01 rhs:01 recursion:01 foo:01 rec':01 polymorphic:01 wrote:01 rec:01 rec:01 Virgile Prevosto wrote: > Le mer 27 jun 2007 12:12:34 CEST, > Jeremy Yallop a écrit : >> OCaml seems a little inconsistent here, actually. The application >> `id 0' is only valid as the rhs of let rec because the compiler can > > 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: You're right; I'd overestimated the extent of the analysis. Note that applications on the rhs of let rec are acceptable if there's no recursion at all involved in the application: let id x = x in let rec f = id id and g x = g (f x) in g Jeremy. > > Objective Caml version 3.10.0 > > # let rec id = fun x -> x and _foo = id 0 in id 1;; > This kind of expression is not allowed as right-hand side of `let rec'