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 2FC5CBC6B for ; Thu, 28 Jun 2007 14:59:34 +0200 (CEST) Received: from moutng.kundenserver.de (moutng.kundenserver.de [212.227.126.171]) by concorde.inria.fr (8.13.6/8.13.6) with ESMTP id l5SCxXfL028859 for ; Thu, 28 Jun 2007 14:59:33 +0200 Received: from [141.84.136.30] (helo=[152.78.96.56]) by mrelayeu.kundenserver.de (node=mrelayeu4) with ESMTP (Nemesis), id 0ML21M-1I3tau421x-0000s4; Thu, 28 Jun 2007 14:59:33 +0200 Message-ID: <4683B0C7.7060201@functionality.de> Date: Thu, 28 Jun 2007 13:59:51 +0100 From: Thomas Fischbacher User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7.12) Gecko/20060607 Debian/1.7.12-1.2 X-Accept-Language: en MIME-Version: 1.0 To: Jon Harrop Cc: caml-list@yquem.inria.fr Subject: Re: [Caml-list] The Implicit Accumulator: a design pattern using optional arguments References: <200706271314.35134.jon@ffconsultancy.com> <200706271653.27116.jon@ffconsultancy.com> <4683950E.3060609@functionality.de> <200706281232.01643.jon@ffconsultancy.com> In-Reply-To: <200706281232.01643.jon@ffconsultancy.com> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Provags-ID: V01U2FsdGVkX1/Af68/GNXarD/etg+qxLaV1NT0GpTGtX1Ykyv UDYgA2uX8IWXI7JISrdbquak42aacme0CMdSqHK8e13RDTBkS4 aGG5Y/Ax4XjNsbt+499VQ== X-Miltered: at concorde with ID 4683B0B5.000 by Joe's j-chkmail (http://j-chkmail . ensmp . fr)! X-Spam: no; 0.00; ocaml:01 compiler:01 iter:01 wrote:01 rec:01 clearer:01 caml-list:01 lisp:01 nums:01 idiomatic:02 idiomatic:02 implicit:03 let:03 let:03 pattern:04 Jon Harrop wrote: > I would write: > > let rec work sum = function > | 0 -> sum > | todo -> work (sum + todo) (todo - 1) > > let sum_nums n = work 0 n > > because it is shorter, clearer, 65% faster and it is idiomatic ML rather than > idiomatic Lisp. You are still evading the issue: you nevertheless pass multiple arguments to a continuation, rather than consing a return value. But apart from this: I find it somehow strange that the OCaml compiler produces noticeable differences in the speed of compiled code when one does some transcriptions that actually should not matter, such as when replacing for with Array.iter... -- best regards, Thomas Fischbacher tf@functionality.de