Mailing list for all users of the OCaml language and system.
 help / color / mirror / Atom feed
From: Brian Hurt <bhurt@janestcapital.com>
To: Christopher L Conway <cconway@cs.nyu.edu>
Cc: caml-list@inria.fr
Subject: Re: [Caml-list] log function without evaluate arguments
Date: Wed, 07 Nov 2007 08:42:59 -0500	[thread overview]
Message-ID: <4731C0E3.1070709@janestcapital.com> (raw)
In-Reply-To: <4a051d930711062010m7e412ffo80480c2b241d8d1d@mail.gmail.com>

[-- Attachment #1: Type: text/plain, Size: 1308 bytes --]

Christopher L Conway wrote:

>On 11/6/07, Erik de Castro Lopo <mle+ocaml@mega-nerd.com> wrote:
>  
>
>>Christopher L Conway wrote:
>>
>>    
>>
>>>On 11/6/07, Brian Hurt <bhurt@janestcapital.com> wrote:
>>>      
>>>
>>>> Also, creating a lazy thunk in Ocaml is expensive (like 140+ clock cycles),
>>>>while passing an argument into a function is cheap- and the common case will
>>>>be that the argument won't need to be evaluated, just passed in.
>>>>        
>>>>
>>>What does this mean? Did OCaml become non-strict while I wasn't looking?
>>>      
>>>
>>Ocaml is strict by default and optionally lazy.
>>
>>The code being discussed was this:
>>
>>    log (lazy (Printf.printf "%s" (awfully_long_computation ())))
>>
>>where everything inside
>>
>>    (lazy X)
>>
>>is lazy evaluated.
>>    
>>
>
>Yes, of course. But, if I understand correctly, Brian was arguing in favor of
>
>   Printf.ifprinf "%s" (awfully_long_computation ())
>
>and claiming that it was potentially more efficient than the lazy version.
>
>  
>
No, I was arguing that:

Printf.ifprintf "%s" "foo"

was more efficient, and was a much more common case.

I was also arguing that:

Printf.ifprintf "%s" (awfully_long_computation ())

was more likely to be correct, especially if awfully_long_computation 
includes side effects.

Brian


[-- Attachment #2: Type: text/html, Size: 2094 bytes --]

  reply	other threads:[~2007-11-07 13:43 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-11-06 17:05 tmp123
2007-11-06 16:57 ` Sylvain Le Gall
2007-11-06 18:25 ` [Caml-list] " Nicolas Pouillard
2007-11-06 18:40   ` Till Varoquaux
2007-11-06 18:49     ` Brian Hurt
2007-11-07  3:39       ` Christopher L Conway
2007-11-07  4:00         ` Erik de Castro Lopo
2007-11-07  4:10           ` Christopher L Conway
2007-11-07 13:42             ` Brian Hurt [this message]
2007-11-07 10:21     ` Nicolas Pouillard
2007-11-07  3:40 ` Christopher L Conway
     [not found] ` <4a051d930711061938u25836a85ud28c610312e5896f@mail.gmail.com>
2007-11-07 10:31   ` tmp123

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=4731C0E3.1070709@janestcapital.com \
    --to=bhurt@janestcapital.com \
    --cc=caml-list@inria.fr \
    --cc=cconway@cs.nyu.edu \
    /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