Evaluation strategy
In
computer science, an evaluation strategy is a set of (usually deterministic) rules for determining the evaluation of
expressions in a
programming language. Emphasis is typically placed on
functions or operators — an evaluation strategy defines when and in what order the arguments to a function are evaluated, when they are substituted into the function, and what form that substitution takes. The
lambda calculus, a formal system for the study of functions, has often been used to model evaluation strategies, where they are usually called reduction strategies. Evaluation strategies divide into two basic groups, strict and non-strict, based on how arguments to a function are handled. A language may combine several evaluation strategies; for example,
C++ combines call-by-value with call-by-reference. Most languages that are predominantly strict use some form of non-strict evaluation for boolean expressions and if-statements.
See more at Wikipedia.org...
call-by-name
(CBN) (Normal order reduction, leftmost, outermost reduction). An argument passing convention (first provided by
ALGOL 60?) where argument expressions are passed unevaluated. This is usually implemented by passing a pointer to some code which will return the value of the argument and an environment giving the values of its
free variables. This
evaluation strategy is guaranteed to reach a
normal form if one exists.
When used to implement
functional programming languages, call-by-name is usually combined with
graph reduction to avoid repeated evaluation of the same expression. This is then known as
call-by-need. The opposite of call-by-name is
call-by-value where arguments are evaluated before they are passed to a function. This is more efficient but is less likely to terminate in the presence of infinite data structures and
recursive functions. Arguments to
macros are usually passed using call-by-name.
(1994-11-29)
(c) Copyright 1993 by Denis Howe