OCaml学习——Substitution-and-Evaluation

Substitution and Evaluation

Implementing OCaml in OCaml Part 2.

Evaluation

Evaluation rewrites the abstact syntax of a program step-by-step until it produces a value.

Example

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
(* raw *)
let x = 30 in
let y = 20 + x in
x + y

->

let y = 20 + 30 in
30 + y

->

let y = 50 in
30 + y

->

30+50

->

80