Today's Idea: What an interpreter is
I explained administrative stuff, especially the collaboration policy and how you must attend tutorials. I recommended that you go to the lab even if you work mostly on your own computer so that you can meet other students and get advice from LAs.
I explained the difference between the computation model most of you
are used to and the one we'll use in this course:
Compilation Model: compiler translates source file to executable; when
executable is run, it reads inputs, changes state, writes outputs.
Interpretation Model: you give interpreter an expression; it evaluates
it and gives you back a value.
I showed you MIT Scheme, our standard environment, and Dr Scheme, an
environment developed at Rice.
To illustrate evaluation, we entered a collection of expressions into
a Scheme interpreter:
We noticed that procedures are values just like numbers, and that parens are special -- they don't have the usual meaning of "grouping".
Then I explained how define "installs" values into the interpreter that later be referenced by name, and we played with this notion:
We saw how to install procedure values:
You then wrote a procedure that computed the area of a disk with inner radius i and outer radius o. I showed you how to organize into in a modular way:
(define pi 3.14)
(define (sq x) (* x x))
(define (area r) (* pi (sq r)))
(define (disk-area inner outer)
(- (area outer) (area inner))
)