Mailing list for all users of the OCaml language and system.
 help / color / mirror / Atom feed
From: Jon Harrop <jon@ffconsultancy.com>
To: caml-list@yquem.inria.fr
Subject: Re: [Caml-list] Curried form different from "normal"
Date: Sun, 5 Feb 2006 18:00:20 +0000	[thread overview]
Message-ID: <200602051800.21213.jon@ffconsultancy.com> (raw)
In-Reply-To: <9d3ec8300602050840ha03fcd2wf8a43bd7a09732f2@mail.gmail.com>

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


  parent reply	other threads:[~2006-02-05 17:57 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-02-05 16:40 Till Varoquaux
2006-02-05 16:59 ` [Caml-list] " David Baelde
2006-02-05 18:00 ` Jon Harrop [this message]
2006-02-05 18:14   ` Till Varoquaux

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=200602051800.21213.jon@ffconsultancy.com \
    --to=jon@ffconsultancy.com \
    --cc=caml-list@yquem.inria.fr \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox