CSc 520 - Principles of Programming Languages
40 : Scheme -- Metacircular Interpretation

Christian Collberg

Department of Computer Science

University of Arizona

1 Introduction

2 Let Expressions


2#2

3 Let Expressions...


3#3

4 Imperative Features

(set! var value)
Change the value of var to value.
(set-car! var value)
Change the car-field of the cons-cell var to value.
(set-cdr! var value)
Change the cdr-field of the cons-cell var to value.

5 Imperative Features...


4#4

6 Dotted Pairs


5#5

7 Dotted Pairs...


6#6

8 Dotted Pairs...


7#7

9 Dotted Pairs...


8#8

10 Loops

Scheme's ``for-loop'' do takes these arguments:

  1. A list of triples (var init update) which declares a variable var, with an initial value init, and which gets updated using the expression update, on each iteration;
  2. A pair (termination_cond return_value) which gives the termination condition and return value of the loop; and
  3. a loop body:


9#9

11 Loops...


10#10

12 Association Lists

13 Association Lists...


12#12

14 Association Lists...

15 Apply


14#14

16 Eval


15#15

17 Eval...


16#16

18 Programs as Data


17#17

19 Evaluation Order


18#18

20 Evaluation Order...


19#19

21 Evaluation Order...


20#20

22 Evaluation Order...


21#21

23 A Metacircular Interpreter


22#22

24 A Metacircular Interpreter...


23#23

25 A Metacircular Interpreter...


24#24

26 A Metacircular Interpreter...

27 A Metacircular Interpreter...


25#25

28 A Metacircular Interpreter...


26#26

29 A Metacircular Interpreter...


27#27

30 A Metacircular Interpreter...

31 Readings and References



Christian Collberg 2008-05-02