<?xml version="1.0" encoding="ISO-8859-1"?>

<!DOCTYPE message PUBLIC
  "-//MLarc//DTD MLarc output files//EN"
  "../../mlarc.dtd"[
  <!ATTLIST message
    listname CDATA #REQUIRED
    title CDATA #REQUIRED
  >
]>

  <?xml-stylesheet href="../../mlarc.xsl" type="text/xsl"?>


<message 
  url="2006/02/6112bba539b885c93cae0b63530988e6"
  from="Jon Harrop &lt;jon@f...&gt;"
  author="Jon Harrop"
  date="2006-02-05T17:57:30"
  subject="Re: [Caml-list] Curried form different from &quot;normal&quot;"
  prev="2006/02/60ec1632c3246656d7b42c04b18ad63f"
  next="2006/02/fd6ef9c32a1154859f9e54b6bb5cc903"
  prev-in-thread="2006/02/1c195e18c279763175e2c125bb32d1fb"
  next-in-thread="2006/02/851635eb4ffea2ab9bcb25f9d631b133"
  prev-thread="2006/02/97ace0c2a51e26bcec579188e650a0e3"
  next-thread="2006/02/21cfe6b7d7d8f6b67ad1bdfb90131fe8"
  root="../../"
  period="month"
  listname="caml-list"
  title="Archives of the Caml mailing list">

<thread subject="Curried form different from &quot;normal&quot;">
<msg 
  url="2006/02/1df604b17c7343a34edde8c4272eced3"
  from="Till Varoquaux &lt;till.varoquaux@g...&gt;"
  author="Till Varoquaux"
  date="2006-02-05T16:40:59"
  subject="Curried form different from &quot;normal&quot;">
<msg 
  url="2006/02/1c195e18c279763175e2c125bb32d1fb"
  from="David Baelde &lt;david.baelde@g...&gt;"
  author="David Baelde"
  date="2006-02-05T16:59:02"
  subject="Re: [Caml-list] Curried form different from &quot;normal&quot;">
</msg>
<msg 
  url="2006/02/6112bba539b885c93cae0b63530988e6"
  from="Jon Harrop &lt;jon@f...&gt;"
  author="Jon Harrop"
  date="2006-02-05T17:57:30"
  subject="Re: [Caml-list] Curried form different from &quot;normal&quot;">
<msg 
  url="2006/02/851635eb4ffea2ab9bcb25f9d631b133"
  from="Till Varoquaux &lt;till.varoquaux@g...&gt;"
  author="Till Varoquaux"
  date="2006-02-05T18:14:35"
  subject="Re: [Caml-list] Curried form different from &quot;normal&quot;">
</msg>
</msg>
</msg>
</thread>

<contents>
On Sunday 05 February 2006 16:40, Till Varoquaux wrote:
&gt;  let non_blank_string=
&gt;       if !is_first then
&gt; 	trailling:=Buffer.contents white
&gt;       else
&gt; 	Buffer.add_buffer buf white;
&gt;       Buffer.reset white;
&gt;       is_first:=false;
&gt;       Buffer.add_string buf
&gt;
&gt;  let non_blank_string s=
&gt;       if !is_first then
&gt; 	trailling:=Buffer.contents white
&gt;       else
&gt; 	Buffer.add_buffer buf white;
&gt;       Buffer.reset white;
&gt;       is_first:=false;
&gt;       Buffer.add_string buf s
&gt;
&gt; Doesn't yeld the same results (the former is buggy). Now, as I
&gt; understand, these two functions should be exactly equivalent. I am
&gt; 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

</contents>

</message>

