Version française
Home     About     Download     Resources     Contact us    

This site is updated infrequently. For up-to-date information, please visit the new OCaml website at

Browse thread
RE: [Caml-list] laziness
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2004-09-06 (09:07)
From: Jason Smith <jns28@s...>
Subject: RE: [Caml-list] laziness
>But that dead code if executed eagerly will result
>in a value stored in a variable which is never used.
>So the code is still 'dead code' and still a bug
>(assuming it is a bug) whether evaluation is eager
>or lazy.

This is where dead code elimination comes into play. A trivial optimization 
performed by the GHC compiler.


let x = <long computation>
    y = ...
in  ...y....

we can remove 'x'.

Again, side-effects make this harder in o'caml.

>Actually the lazy case might make it easier to
>track this down by adding a debugging print
>in the expression -- in the eager case you get
>a diagnostic but can't deduce the result is used,
>in the lazy case you know the result is being used
>when you get the diagnostic.

The compiler should optimize it out. There shouldn't be any need for using 
explicit print statements.


To unsubscribe, mail Archives:
Bug reports: FAQ:
Beginner's list: