Browse thread
[Caml-list] laziness
-
skaller
-
Marcin 'Qrczak' Kowalczyk
-
skaller
- Richard Jones
- Hartmann Schaffer
-
skaller
- Jon Harrop
-
Marcin 'Qrczak' Kowalczyk
[
Home
]
[ Index:
by date
|
by threads
]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
| Date: | -- (:) |
| From: | Richard Jones <rich@a...> |
| Subject: | Re: [Caml-list] laziness |
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/