unit_4_lexical_scope_functional_lang.pptx - Approaches to Expression Evaluation \u2022Innermost Evaluation \u2022Outermost Evaluation \u2022Selective Evaluation

unit_4_lexical_scope_functional_lang.pptx - Approaches to...

This preview shows page 1 - 5 out of 13 pages.

Approaches to Expression Evaluation Innermost Evaluation Outermost Evaluation Selective Evaluation Evaluation of Recursive Functions Short-Circuit Evaluation
Image of page 1
Innermost Evaluation Under the innermost-evaluation rule, a function application < name > < actual- parameter > is computed as follows: Evaluate the expression represented by < actual- parameter>. Substitute the result for the formal in the function body. Evaluate the body and return its value as the answer. e.g: fun successor n = n + 1 ; successor (2+3) 2 + 3 = 5 successor (5)
Image of page 2
Outermost Evaluation Under the outermost-evaluation rule, a function is computed as follows Substitute the actual parameter for the formal in the function body. Evaluate the body and return its value as the answer. e.g: fun successor n = n + 1 successor (2 + 3) n = 2+3+1 = 6 The answer is the same in both the cases.
Image of page 3
Selective Evaluation The ability to evaluate selectively some parts of an expression and ignore others is provided by the construct if < condition > then < expression 1 > else < expression 2 >
Image of page 4
Image of page 5

You've reached the end of your free preview.

Want to read all 13 pages?

  • Fall '19

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture