Version française
Home     About     Download     Resources     Contact us    
Browse thread
[Caml-list] laziness
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Hartmann Schaffer <schaffer@a...>
Subject: Re: [Caml-list] laziness
skaller wrote:

>On Sat, 2004-09-04 at 18:40, Marcin 'Qrczak' Kowalczyk wrote:
>  
>
>>skaller <skaller@users.sourceforge.net> writes:
>>
>>    
>>
>>>However if the call is *inlined* to get
>>>
>>>	if c' then a' else b'
>>>
>>>then perhaps a' or b' will never be evaluated.
>>>      
>>>
>>No. Inlining is considered an optimization, which implies that it
>>doesn't change the semantics except when it was not fully specified
>>in the first place.
>>    
>>
>
>I understand that argument -- but that doesn't mean the
>compiler conforms to the specification, nor that the
>specification is best.
>
>  
>
>>E.g. the order of evaluation of arguments is
>>unspecified, so it might be different depending on inlining; but
>>OCaml does specify that each argument are evaluated exactly once
>>and inlining doesn't change that.
>>    
>>
>
>Must they be evaluated before the function is called?
>
>  
>
on the first pass, yes (in order maintain the meaning of the code).  
depending on the optimizer, later optimizations might be able to 
suppress some of the evaluations (e.g. if the value of c' can be 
determined at compile time)

hs

-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners