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 A50FFBC6B for ; Wed, 27 Jun 2007 13:29:46 +0200 (CEST) Received: from orion.metastack.com (no-dns-yet.demon.co.uk [80.177.38.218] (may be forged)) by discorde.inria.fr (8.13.6/8.13.6) with ESMTP id l5RBTjXT030039 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=FAIL) for ; Wed, 27 Jun 2007 13:29:46 +0200 Received: from treble (cpc2-cmbg6-0-0-cust535.cmbg.cable.ntl.com [81.107.34.24]) (authenticated bits=0) by orion.metastack.com (8.13.4/8.13.3) with ESMTP id l5RBMUXX017132 (version=TLSv1/SSLv3 cipher=RC4-MD5 bits=128 verify=NO) for ; Wed, 27 Jun 2007 12:22:30 +0100 From: "David Allsopp" To: "OCaml List" References: <20070627100004.9E0DABC73@yquem.inria.fr> <001801c7b8a5$672a2b80$6a7ba8c0@treble> <46824622.2080508@ed.ac.uk> Subject: RE: [Caml-list] let rec and polymorphic functions Date: Wed, 27 Jun 2007 12:29:45 +0100 Organization: MetaStack Solutions Ltd. Message-ID: <002d01c7b8ae$76a45550$6a7ba8c0@treble> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Mailer: Microsoft Office Outlook 11 Thread-Index: Ace4qpgn2NzyvSBAQzmUgowh4di8BAAA622g X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.3028 In-Reply-To: <46824622.2080508@ed.ac.uk> X-Miltered: at discorde with ID 46824A29.001 by Joe's j-chkmail (http://j-chkmail . ensmp . fr)! X-Spam: no; 0.00; recursive:01 ocaml:01 rhs:01 compiler:01 recursion:01 polymorphism:01 recursive:01 ocaml:01 bug:01 sml:01 sml:01 polymorphic:01 rec:01 rec:01 caml-list:01 > 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 Thanks for this. I see the SML difference now - let fun id x = x and g x = id 0 + x in id () end; similarly doesn't work in SML with a pair of functions instead. > OCaml seems a little inconsistent here, actually. The application `id > 0' is only valid as the rhs of let rec because the compiler can > determine that there's no actual recursion involved. There doesn't > seem to be a reason not to apply a similar analysis to type checking, > allowing more polymorphism for functions in the same recursive group > that aren't actually part of a cycle. Which is what SML did in my "equivalent" example - and it would certainly be nice if OCaml did the same. Is it worth raising a bug (well, feature request) for or am I the only person who (ab)uses [let rec] in this way? Many thanks, David