Uploaded by Branson Lam

Substitution Model Cheat Sheet

advertisement
Evaluation of Statements
(function declarations are abbreviations for constant declarations)
Expression
statements
Evaluate the expression
Blocks
Evaluate its statement sequence; If first statement is
a declaration: const x = e; evaluate e and replace x
by the result in the scope of x
Sequences
Evaluate statements top-down; keep value of last
statement
Conditional
statements
Evaluate predicate; if predicate is true: evaluate the
consequent statement, if false, evaluate the
alternative statement
Evaluation of Expressions
(lambda expressions are considered to be “value expressions”)
Value
expressions
Just take the value
Operator
combinations
Evaluate operands, apply operation
Conditional
expressions
Evaluate predicate; if predicate is true: evaluate the
consequent expression, if false, evaluate the
alternative expression
Conditional
statements
Evaluate predicate; if predicate is true: evaluate the
consequent statement, if false, evaluate the
alternative statement
Function
applications
Evaluate components; if the function expression is a
lambda expression, evaluate the body of the
lambda expression, after replacing the parameters
by the argument expressions
Block
expressions
Like block statements; if the first statement is a
return statement, evaluate return expression
Download