Strict Evaluation

Strict evaluation is where all arguments to a function are evaluated before the body of the function is evaluated; and the arguments are never re-evaluated. In other words, each argument is evaluated exactly once. Compare with LazyEvaluation and NormalOrderEvaluation.

Most languages uses StrictEvaluation for function arguments (though not for macros and some special forms). SchemeLanguage uses StrictEvaluation by default; by using delay/force one can cause an argument to be evaluated with LazyEvaluation instead. Some functional languages such as HaskellLanguage use LazyEvaluation by default.

Note that StrictEvaluation does not define the order in which arguments are evaluated; that is up to the language. Some languages use left-to-right, others right-to-left; and others (such as CeeLanguage and CeePlusPlus) leave this unspecified (any program which depends on the order of evaluation is unportable/ill-formed in such a language).

If all you have is StrictEvaluation, the other forms can be simulated by wrapping the expression to be evaluated in a LambdaExpression, object, thunk, etc.


See also ParameterPassing, CallByValue, CallByThunk
CategoryLanguageFeature

EditText of this page (last edited February 5, 2005) or FindPage with title or text search