Question: 5 . ( 2 points ) Operation Semantics Rules ( a ) ( 1 point ) Consider the operation semantics rules for function calls (
points Operation Semantics Rules a point Consider the operation semantics rules for function calls or function applications presented in Lecture or Assignment : EAGEREval A ; e fun x e A ; e v A x: v ; e vA ; e e v We call this rule EAGEREval because it evaluates the function application argument e to a value before evaluating the function body e from e Using this evaluation rule, the interpreter can reduce the OCaml program fun x fun y x y fun c c fun a a fun b b in the following few steps we omit the environment A for simplicity: fun x fun y x y fun c c fun a a fun b b; fun y fun c c y fun a a fun b b; fun y fun c c y fun b b; fun c c fun b b; fun b b; It is important to note that function application is leftassociative eg x y z x y z We now define a new function application evaluation rule called LAZYEvAL as follows: LAZYEvaL A ; e fun x e A ; ee x vA ; e e v Here, ee x means "the expression after substituting occurrences of x in e with e The key point is that we defer the evaluation of the functional application argument e until it has to be evaluated. This is often referred as "lazy evaluation". Reduce the same OCaml program fun x fun y x y fun c c fun a afun b b using this new evaluation rule to witness the key difference between EAGEREval and LAzyEval.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
