Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Eager evaluation/applicative order and lazy evaluation/normal order

As far as I know, eager evaluation/applicative order evaluates all arguments to a function before applying it, on the other hand, lazy evaluation/normal order evaluates the arguments only when needed.

So, what are the differences between the pair of terms eager evaluation and applicative order, and lazy evaluation and normal order?

Thanks.

like image 426
Ryan Li Avatar asked Jan 08 '11 15:01

Ryan Li


People also ask

What is the difference between normal order and applicative order evaluation?

While applicative order proceeds by evaluating the subexpressions and then applying the function, normal order evaluation proceeds by applying the function first and then evaluating the subexpressions.

What is difference between eager and lazy evaluation?

Eager evaluation means expression is evaluated as soon as it is encountered where as lazy evaluation refers to evaluation of an expression when needed.

What is applicative order?

Applicative order is a family of evaluation orders in which a function's arguments are evaluated completely before the function is applied.

Is lambda calculus lazy evaluation?

Lazy evaluation was introduced for lambda calculus by Christopher Wadsworth and employed by the Plessey System 250 as a critical part of a Lambda-Calculus Meta-Machine, reducing the resolution overhead for access to objects in a capability-limited address space.


1 Answers

Lazy evaluation evaluates a term at most once, while normal order would evaluate it as often as it appears. So for example if you have f(x) = x+x and you call it as f(g(42)) then g(42) is called once under lazy evaluation or applicative order, but twice under normal order.

Eager evaluation and applicative order are synonymous, at least when using the definition of applicative order found in Structure and Interpretation of Computer Programs, which seems to match yours. (Wikipedia defines applicative order a bit differently and has it as a special case of eager evaluation).

like image 160
sepp2k Avatar answered Sep 23 '22 03:09

sepp2k