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,HTML_MESSAGE autolearn=disabled version=3.1.3 X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from mail3-relais-sop.national.inria.fr (mail3-relais-sop.national.inria.fr [192.134.164.104]) by yquem.inria.fr (Postfix) with ESMTP id DD5B1BC6B for ; Wed, 7 Nov 2007 14:43:08 +0100 (CET) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AgAAAEpOMUfAXQImh2dsb2JhbACCc4wJAQEBCAop X-IronPort-AV: E=Sophos;i="4.21,384,1188770400"; d="scan'208,217";a="5545248" Received: from discorde.inria.fr ([192.93.2.38]) by mail3-smtp-sop.national.inria.fr with ESMTP; 07 Nov 2007 14:43:08 +0100 Received: from mail4-relais-sop.national.inria.fr (mail4-relais-sop.national.inria.fr [192.134.164.105]) by discorde.inria.fr (8.13.6/8.13.6) with ESMTP id lA7Dh78d006890 (version=TLSv1/SSLv3 cipher=RC4-SHA bits=128 verify=OK) for ; Wed, 7 Nov 2007 14:43:08 +0100 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: Ao8CADhQMUdCm3xr/2dsb2JhbACCcw X-IronPort-AV: E=Sophos;i="4.21,384,1188770400"; d="scan'208,217";a="19031790" Received: from www.janestcapital.com (HELO smtp.janestcapital.com) ([66.155.124.107]) by mail4-smtp-sop.national.inria.fr with ESMTP; 07 Nov 2007 14:43:01 +0100 Received: from [172.25.129.161] [38.96.172.125] by janestcapital.com with ESMTP (SMTPD-9.10) id A0E30620; Wed, 07 Nov 2007 08:42:59 -0500 Message-ID: <4731C0E3.1070709@janestcapital.com> Date: Wed, 07 Nov 2007 08:42:59 -0500 From: Brian Hurt User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7.2) Gecko/20040804 Netscape/7.2 (ax) X-Accept-Language: en-us, en MIME-Version: 1.0 To: Christopher L Conway Cc: caml-list@inria.fr Subject: Re: [Caml-list] log function without evaluate arguments References: <47309EEC.4080706@menta.net> <1194373338-sup-9994@ausone.local> <9d3ec8300711061040l424aac69y4b859a029d815089@mail.gmail.com> <4730B72B.3000109@janestcapital.com> <4a051d930711061939p621c0a8ao4472a82973dcc855@mail.gmail.com> <20071107150016.61b256ac.mle+ocaml@mega-nerd.com> <4a051d930711062010m7e412ffo80480c2b241d8d1d@mail.gmail.com> In-Reply-To: <4a051d930711062010m7e412ffo80480c2b241d8d1d@mail.gmail.com> Content-Type: multipart/alternative; boundary="------------060807080501060108060507" X-Miltered: at discorde with ID 4731C0EB.000 by Joe's j-chkmail (http://j-chkmail . ensmp . fr)! X-Spam: no; 0.00; ocaml:01 ocaml:01 printf:01 printf:01 foo:01 foo:01 wrote:01 wrote:01 caml-list:01 computation:01 computation:01 lazy:02 lazy:02 argument:02 argument:02 This is a multi-part message in MIME format. --------------060807080501060108060507 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Christopher L Conway wrote: >On 11/6/07, Erik de Castro Lopo wrote: > > >>Christopher L Conway wrote: >> >> >> >>>On 11/6/07, Brian Hurt 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 --------------060807080501060108060507 Content-Type: text/html; charset=us-ascii Content-Transfer-Encoding: 7bit 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

--------------060807080501060108060507--