CSE-321 Programming Languages
Evaluation Contexts
POSTECH
April 16, 2007
박성우
2
Simply Typed -Calculus
3
18 Reduction Rules
4
Simpler?
5
Outline• Evaluation contexts• Abstract machine C
6
Reduction Rules
7
Derivation Trees
8
Reducing an Expression e1. Locate an appropriate subexpression (redex) of e
2. Apply a corresponding reduction rule
9
Locate and Apply
10
Decompose and Apply
=+
11
Decompose and Apply
=+
Expression
Redex
Context remaining intact
12
Evaluation Contexts (CBV)• An expression with a hole ¤ in it• The hole ¤ indicates the position of a subexpression
to be reduced in the next step,i.e., the redex for the next step.
• Example:
13
Reduction Strategy• Determined by the definition of evaluation contexts
call-by-name
call-by-value
14
15
Reduction Rule
16
Example
17
Still Cryptic?
18
Outline• Evaluation contexts V• Abstract machine C
19
This Rule is a Sagi.
20
Example• Implicit analysis
• Explicit analysis
21
Abstract Machine C• Explicit decomposition of a given expression• Uses a stack of frames instead of evaluation
contexts.• Each frame corresponds to a specific step in the
decomposition.
22
Example
23
State of the Machine
24
Example
25
26
Outline• Evaluation contexts V• Abstract machine C V• Something important!
27
Midterm• Three hours, closed book• 20% toward your final grade• Next Wednesday, 8pm - 11pm, in the classroom
April 2007 Su Mo Tu We Th Fr Sa 16 17 18 19 20 2122 23 24 25 26 27 28