expression evaluation Flashcards
1
Q
how are expressions evaluated?
A
most exprs are simple, evaluate E1 and E2 and combine them
2
Q
short circuit evaluation
A
E1 orelse E2
E1 andalso E2
3
Q
function evaluation
A
two common methods: leftmost innermost and leftmost outermost
4
Q
leftmost innermost
A
• args evaluated from L to R
ª start with innermost expr
• args evaluated before function call
• each arg is evaluated exactly once
5
Q
leftmost outermost
A
- args evaluated from L to R
- start with outermost expr
- args evaluated as needed
- each arg evaluated 0 or more times
6
Q
innermost
A
- EVE (eager, value, efficient)
- call by value (eager)
- generally more efficient
7
Q
outermost
A
- LENT (lazy, name, terminates)
- call by name (lazy)
- may terminated in cases where innermost does not