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 Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by yquem.inria.fr (Postfix) with ESMTP id 51A8CBC0A for ; Sat, 19 May 2007 18:06:27 +0200 (CEST) Received: from ipmail01.adl2.internode.on.net (ipmail01.adl2.internode.on.net [203.16.214.140]) by concorde.inria.fr (8.13.6/8.13.6) with ESMTP id l4JG6ONV032610 for ; Sat, 19 May 2007 18:06:26 +0200 X-IronPort-AV: E=Sophos;i="4.14,556,1170595800"; d="scan'208";a="131178383" Received: from ppp59-172.lns2.syd6.internode.on.net (HELO [192.168.1.201]) ([121.44.59.172]) by ipmail01.adl2.internode.on.net with ESMTP; 20 May 2007 01:36:23 +0930 Subject: Re: [Caml-list] tail rec From: skaller To: Oliver Bandel Cc: caml-list@inria.fr In-Reply-To: <20070519144651.GD335@first.in-berlin.de> References: <1179543365.26755.33.camel@rosella.wigram> <20070519142827.GA335@first.in-berlin.de> <20070519144651.GD335@first.in-berlin.de> Content-Type: text/plain Date: Sun, 20 May 2007 02:06:22 +1000 Message-Id: <1179590782.18119.90.camel@rosella.wigram> Mime-Version: 1.0 X-Mailer: Evolution 2.10.1 Content-Transfer-Encoding: 7bit X-Miltered: at concorde with ID 464F2080.002 by Joe's j-chkmail (http://j-chkmail . ensmp . fr)! X-Spam: no; 0.00; 0200,:01 bandel:01 ocaml:01 recursion:01 annotations:01 idioms:01 semantics:01 annotation:01 suboptimal:01 bug:01 sourceforge:01 wrote:01 oliver:01 rec:01 syntactic:01 On Sat, 2007-05-19 at 16:46 +0200, Oliver Bandel wrote: > > I think this is blocking understanding of how ressources > > are allocated, when one uses a certain style of programming > > and datastructures. > > Forget these words: I misunderstood your email, > because I did not read until end before I answered. > Sorry for the unnecessary traffic. Actually you make an important point! > I thought you want to automatically *convert* > code to tailrec-code. Well that would be totally cool, but it appears to be a rather hard problem? > Even if this would > also be a fine thing, it could block understanding, > as mentioned above. Actually, you DO have an important point here. When looking at, say, ordinary Ocaml code, it is important to learn about recursion. Examining the syntactic structure of the code to understand the 'different' uses of a simple but powerful primitive in an 'idiomatic' way is important for understanding functional programming. The use of sugar, annotations, or other device to assure certain properties may well hide these idioms, making learning and recognizing them harder. I say 'may' because I'm only one individual, and not a teacher familiar with learning experiences of many people. > But you only want to have warnings... > ...that might be a good helper. Actually no: if you write let tailrec ... then if a direct call of f is not in tail position, you get a hard error, not a warning. The construction has definite semantics. That applies to Basile's more local annotation too. In both cases the error indicates either that the routine is possibly suboptimal in performance, or even that there is a semantic bug in it! -- John Skaller Felix, successor to C++: http://felix.sf.net