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
Parameter evaluation order
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: skaller <skaller@u...>
Subject: Re: [Caml-list] Parameter evaluation order
On Mon, 2005-08-22 at 18:50 +0200, Damien Doligez wrote:

> Suppose you want to evaluate a curried function call in left-to-right  
> order:
> f e1 e2 e3 e4
> You must evaluate f first, then e1.  Then you must apply f to e1, giving
> a new function g1.  Then you must evalue e2, then apply f1 to e2, giving
> f2, etc.
> That's because f might do some side effects between its arguments.   

what data, and possibly annotations, would be required to solve this

For example if all functions are total and pure 
then the above problem vanishes.

Felix doesn't permit functions to have side-effects,
however this isn't enough for full optimisation in 
the presence of exceptions, for example. Additionally,
lazy evaluation can save the setting of a variable,
a sufficient condition being purity (non-dependence on variables
as well as having no side-effects) *and* totality.

Seems like these properties:

* writes variables (side-effect)
* reads variables (side-dependence)
* raises exception
* fails to terminate

impact evaluation strategy. It would be good to know which
properties of things would allow which evaluation strategies.

John Skaller <skaller at users dot sourceforge dot net>