From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by yquem.inria.fr (Postfix) with ESMTP id A0073BBA7 for ; Sun, 5 Feb 2006 18:57:30 +0100 (CET) Received: from pih-relay05.plus.net (pih-relay05.plus.net [212.159.14.132]) by concorde.inria.fr (8.13.0/8.13.0) with ESMTP id k15HvTAO012676 (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NO) for ; Sun, 5 Feb 2006 18:57:30 +0100 Received: from [80.229.56.224] (helo=chetara) by pih-relay05.plus.net with esmtp (Exim) id 1F5o8Z-0003je-9W for caml-list@yquem.inria.fr; Sun, 05 Feb 2006 17:57:23 +0000 From: Jon Harrop Organization: Flying Frog Consultancy Ltd. To: caml-list@yquem.inria.fr Subject: Re: [Caml-list] Curried form different from "normal" Date: Sun, 5 Feb 2006 18:00:20 +0000 User-Agent: KMail/1.8.2 References: <9d3ec8300602050840ha03fcd2wf8a43bd7a09732f2@mail.gmail.com> In-Reply-To: <9d3ec8300602050840ha03fcd2wf8a43bd7a09732f2@mail.gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200602051800.21213.jon@ffconsultancy.com> X-Miltered: at concorde with ID 43E63C8A.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Spam: no; 0.00; caml-list:01 curried:01 buffer:01 buffer:01 buf:01 buf:01 invocation:01 ocaml:01 frog:98 wrote:01 functions:01 caml:02 blank:97 blank:97 objective:02 X-Spam-Checker-Version: SpamAssassin 3.0.3 (2005-04-27) on yquem.inria.fr X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=none autolearn=disabled version=3.0.3 On Sunday 05 February 2006 16:40, Till Varoquaux wrote: > let non_blank_string= > if !is_first then > trailling:=Buffer.contents white > else > Buffer.add_buffer buf white; > Buffer.reset white; > is_first:=false; > Buffer.add_string buf > > let non_blank_string s= > if !is_first then > trailling:=Buffer.contents white > else > Buffer.add_buffer buf white; > Buffer.reset white; > is_first:=false; > Buffer.add_string buf s > > Doesn't yeld the same results (the former is buggy). Now, as I > understand, these two functions should be exactly equivalent. I am > misunderstanding something here? The code preceding the call to "Buffer.add_string" is only evaluated once in the former case (at the time of definition) whereas it is evaluated at each invocation of the latter definition of "non_blank_string". You should not have expected these two definitions to be "exactly equivalent" as the former is equivalent to: if !is_first then trailling:=Buffer.contents white else Buffer.add_buffer buf white;; Buffer.reset white;; is_first:=false;; let non_blank_string = Buffer.add_string buf -- Dr Jon D Harrop, Flying Frog Consultancy Ltd. Objective CAML for Scientists http://www.ffconsultancy.com/products/ocaml_for_scientists