caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Richard Jones <rich@annexia.org>
Cc: caml-list@pauillac.inria.fr
Subject: Re: [Caml-list] laziness
Date: Sat, 4 Sep 2004 12:49:37 +0100	[thread overview]
Message-ID: <20040904114937.GA24148@annexia.org> (raw)
In-Reply-To: <1094296869.3352.280.camel@pelican.wigram>

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

Should be easy enough to test this:

-------------------------------------------------------------- iftest.ml
let f a b c =
  if c then a else b

let r =
  f (print_endline "function a"; 'a')
    (print_endline "function b"; 'b')
    true;;

Printf.printf "r = %c\n" r
----------------------------------------------------------------------

When compiled with ocamlc and run, this prints:

function b
function a
r = a

When compiled with ocamlopt -inline 99 and run, this prints:

function a
function b
r = a

I examined the assembler output from ocamlopt, and it looks to me like
it's doing inlining and significant optimizations.

So it all works fine, I think.

Rich.

-- 
Richard Jones. http://www.annexia.org/ http://www.j-london.com/
Merjis Ltd. http://www.merjis.com/ - improving website return on investment
MONOLITH is an advanced framework for writing web applications in C, easier
than using Perl & Java, much faster and smaller, reusable widget-based arch,
database-backed, discussion, chat, calendaring:
http://www.annexia.org/freeware/monolith/

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 189 bytes --]

  reply	other threads:[~2004-09-04 11:49 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-09-04  6:30 skaller
2004-09-04  8:40 ` Marcin 'Qrczak' Kowalczyk
2004-09-04 11:21   ` skaller
2004-09-04 11:49     ` Richard Jones [this message]
2004-09-04 20:40     ` Hartmann Schaffer
2004-09-05 10:50 ` Jon Harrop
2004-09-05 14:07   ` skaller
2004-09-05  1:07 Jason Smith
2004-09-05  5:46 ` skaller
2004-09-06  0:57 ` Richard Jones
2004-09-06  6:11   ` Nicolas Cannasse
2004-09-06  8:24   ` skaller
2004-09-06  8:44   ` Erik de Castro Lopo
2004-09-06 12:55   ` Jon Harrop
2004-09-06 16:21     ` William Lovas
2004-09-06 22:35   ` Hartmann Schaffer
2004-09-07  8:31     ` Richard Jones
2004-09-07  8:37       ` Nicolas Cannasse
2004-09-06  9:07 Jason Smith
2004-09-06 10:18 ` skaller
2004-09-06  9:16 Jason Smith
2004-09-06 12:17 Jason Smith
2004-09-06 17:00 ` skaller

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=20040904114937.GA24148@annexia.org \
    --to=rich@annexia.org \
    --cc=caml-list@pauillac.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;
as well as URLs for NNTP newsgroup(s).