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=AWL 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 7A629BC6B for ; Thu, 28 Jun 2007 16:48:47 +0200 (CEST) Received: from ptb-relay02.plus.net (ptb-relay02.plus.net [212.159.14.213]) by concorde.inria.fr (8.13.6/8.13.6) with ESMTP id l5SEmknM030931 (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NO) for ; Thu, 28 Jun 2007 16:48:47 +0200 Received: from [80.229.56.224] (helo=beast.local) by ptb-relay02.plus.net with esmtp (Exim) id 1I3vIc-00007V-9X for caml-list@yquem.inria.fr; Thu, 28 Jun 2007 15:48:46 +0100 From: Jon Harrop Organization: Flying Frog Consultancy Ltd. To: caml-list@yquem.inria.fr Subject: Re: [Caml-list] The Implicit Accumulator: a design pattern using optional arguments Date: Thu, 28 Jun 2007 15:43:01 +0100 User-Agent: KMail/1.9.7 References: <200706271314.35134.jon@ffconsultancy.com> <200706281405.22424.jon@ffconsultancy.com> <4683B89B.1090306@functionality.de> In-Reply-To: <4683B89B.1090306@functionality.de> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200706281543.01424.jon@ffconsultancy.com> X-Miltered: at concorde with ID 4683CA4E.000 by Joe's j-chkmail (http://j-chkmail . ensmp . fr)! X-Spam: no; 0.00; constructors:01 constructors:01 allocator:01 ocaml:01 allocator:01 ocaml:01 frog:98 wrote:01 wrote:01 rewrite:01 caml-list:01 cps:02 cps:02 avoiding:03 implicit:03 On Thursday 28 June 2007 14:33:15 Thomas Fischbacher wrote: > Jon Harrop wrote: > >>You are still evading the issue: you nevertheless pass multiple arguments > >> to a continuation, rather than consing a return value. > > > > Continuations and consing have nothing to do with this. > > Continuations and consing was what the discussion was about > before you changed the subject. I am more than happy to talk about continuations and consing but you need to post code that uses continuations or conses before anyone can help. On Thursday 28 June 2007 12:18:44 Thomas Fischbacher wrote: > > > Pattern matching requires constructors, which cons. > ... > You are evading the question. You didn't ask a question. You made an incorrect statement: "Pattern matching requires constructors, which cons". In the context of avoiding allocation, that is a critical misunderstanding as there was no allocation to avoid. > How do you return two arguments from a function without constructing a > 2-tuple (which is a consing operation). You can rewrite: let f() = 3, 4 let g() = let x, y = f() in x + y in CPS as: let f k = k 3 4 let g = f ( + ) Performance is within 1%. > A continuation call to a higher order function is one way to get > something similar to MULTIPLE-VALUE-*. Not really. Lisp's MULTIPLE-VALUE-* is used to avoid Lisp's heinously slow allocator. OCaml opted for a fast allocator and no MULTIPLE-VALUE-*. > But often, this is a hack. Using CPS to avoid inefficiencies that don't exist is certainly a bad idea. > According to your usually-screwed-up metrics... Time taken? -- Dr Jon D Harrop, Flying Frog Consultancy Ltd. The OCaml Journal http://www.ffconsultancy.com/products/ocaml_journal/?e