cse-321 programming languages evaluation contexts
DESCRIPTION
CSE-321 Programming Languages Evaluation Contexts. 박성우. POSTECH April 16, 2007. Simply Typed -Calculus. 18 Reduction Rules. Simpler?. Outline. Evaluation contexts Abstract machine C. Reduction Rules. Derivation Trees. Reducing an Expression e. - PowerPoint PPT PresentationTRANSCRIPT
![Page 1: CSE-321 Programming Languages Evaluation Contexts](https://reader035.vdocuments.site/reader035/viewer/2022081501/56813ac2550346895da2d323/html5/thumbnails/1.jpg)
CSE-321 Programming Languages
Evaluation Contexts
POSTECH
April 16, 2007
박성우
![Page 2: CSE-321 Programming Languages Evaluation Contexts](https://reader035.vdocuments.site/reader035/viewer/2022081501/56813ac2550346895da2d323/html5/thumbnails/2.jpg)
2
Simply Typed -Calculus
![Page 3: CSE-321 Programming Languages Evaluation Contexts](https://reader035.vdocuments.site/reader035/viewer/2022081501/56813ac2550346895da2d323/html5/thumbnails/3.jpg)
3
18 Reduction Rules
![Page 4: CSE-321 Programming Languages Evaluation Contexts](https://reader035.vdocuments.site/reader035/viewer/2022081501/56813ac2550346895da2d323/html5/thumbnails/4.jpg)
4
Simpler?
![Page 5: CSE-321 Programming Languages Evaluation Contexts](https://reader035.vdocuments.site/reader035/viewer/2022081501/56813ac2550346895da2d323/html5/thumbnails/5.jpg)
5
Outline• Evaluation contexts• Abstract machine C
![Page 6: CSE-321 Programming Languages Evaluation Contexts](https://reader035.vdocuments.site/reader035/viewer/2022081501/56813ac2550346895da2d323/html5/thumbnails/6.jpg)
6
Reduction Rules
![Page 7: CSE-321 Programming Languages Evaluation Contexts](https://reader035.vdocuments.site/reader035/viewer/2022081501/56813ac2550346895da2d323/html5/thumbnails/7.jpg)
7
Derivation Trees
![Page 8: CSE-321 Programming Languages Evaluation Contexts](https://reader035.vdocuments.site/reader035/viewer/2022081501/56813ac2550346895da2d323/html5/thumbnails/8.jpg)
8
Reducing an Expression e1. Locate an appropriate subexpression (redex) of e
2. Apply a corresponding reduction rule
![Page 9: CSE-321 Programming Languages Evaluation Contexts](https://reader035.vdocuments.site/reader035/viewer/2022081501/56813ac2550346895da2d323/html5/thumbnails/9.jpg)
9
Locate and Apply
![Page 10: CSE-321 Programming Languages Evaluation Contexts](https://reader035.vdocuments.site/reader035/viewer/2022081501/56813ac2550346895da2d323/html5/thumbnails/10.jpg)
10
Decompose and Apply
=+
![Page 11: CSE-321 Programming Languages Evaluation Contexts](https://reader035.vdocuments.site/reader035/viewer/2022081501/56813ac2550346895da2d323/html5/thumbnails/11.jpg)
11
Decompose and Apply
=+
Expression
Redex
Context remaining intact
![Page 12: CSE-321 Programming Languages Evaluation Contexts](https://reader035.vdocuments.site/reader035/viewer/2022081501/56813ac2550346895da2d323/html5/thumbnails/12.jpg)
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:
![Page 13: CSE-321 Programming Languages Evaluation Contexts](https://reader035.vdocuments.site/reader035/viewer/2022081501/56813ac2550346895da2d323/html5/thumbnails/13.jpg)
13
Reduction Strategy• Determined by the definition of evaluation contexts
call-by-name
call-by-value
![Page 14: CSE-321 Programming Languages Evaluation Contexts](https://reader035.vdocuments.site/reader035/viewer/2022081501/56813ac2550346895da2d323/html5/thumbnails/14.jpg)
14
![Page 15: CSE-321 Programming Languages Evaluation Contexts](https://reader035.vdocuments.site/reader035/viewer/2022081501/56813ac2550346895da2d323/html5/thumbnails/15.jpg)
15
Reduction Rule
![Page 16: CSE-321 Programming Languages Evaluation Contexts](https://reader035.vdocuments.site/reader035/viewer/2022081501/56813ac2550346895da2d323/html5/thumbnails/16.jpg)
16
Example
![Page 17: CSE-321 Programming Languages Evaluation Contexts](https://reader035.vdocuments.site/reader035/viewer/2022081501/56813ac2550346895da2d323/html5/thumbnails/17.jpg)
17
Still Cryptic?
![Page 18: CSE-321 Programming Languages Evaluation Contexts](https://reader035.vdocuments.site/reader035/viewer/2022081501/56813ac2550346895da2d323/html5/thumbnails/18.jpg)
18
Outline• Evaluation contexts V• Abstract machine C
![Page 19: CSE-321 Programming Languages Evaluation Contexts](https://reader035.vdocuments.site/reader035/viewer/2022081501/56813ac2550346895da2d323/html5/thumbnails/19.jpg)
19
This Rule is a Sagi.
![Page 20: CSE-321 Programming Languages Evaluation Contexts](https://reader035.vdocuments.site/reader035/viewer/2022081501/56813ac2550346895da2d323/html5/thumbnails/20.jpg)
20
Example• Implicit analysis
• Explicit analysis
![Page 21: CSE-321 Programming Languages Evaluation Contexts](https://reader035.vdocuments.site/reader035/viewer/2022081501/56813ac2550346895da2d323/html5/thumbnails/21.jpg)
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.
![Page 22: CSE-321 Programming Languages Evaluation Contexts](https://reader035.vdocuments.site/reader035/viewer/2022081501/56813ac2550346895da2d323/html5/thumbnails/22.jpg)
22
Example
![Page 23: CSE-321 Programming Languages Evaluation Contexts](https://reader035.vdocuments.site/reader035/viewer/2022081501/56813ac2550346895da2d323/html5/thumbnails/23.jpg)
23
State of the Machine
![Page 24: CSE-321 Programming Languages Evaluation Contexts](https://reader035.vdocuments.site/reader035/viewer/2022081501/56813ac2550346895da2d323/html5/thumbnails/24.jpg)
24
Example
![Page 25: CSE-321 Programming Languages Evaluation Contexts](https://reader035.vdocuments.site/reader035/viewer/2022081501/56813ac2550346895da2d323/html5/thumbnails/25.jpg)
25
![Page 26: CSE-321 Programming Languages Evaluation Contexts](https://reader035.vdocuments.site/reader035/viewer/2022081501/56813ac2550346895da2d323/html5/thumbnails/26.jpg)
26
Outline• Evaluation contexts V• Abstract machine C V• Something important!
![Page 27: CSE-321 Programming Languages Evaluation Contexts](https://reader035.vdocuments.site/reader035/viewer/2022081501/56813ac2550346895da2d323/html5/thumbnails/27.jpg)
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