Kind of expression Examples How to evaluate
Value 17, true, 'arugula You have the value already.
Placeholder pi, + Get its defined value.
Function application (+ (* 9 4) pi), (fahr->celc -40) Evaluate the subexpressions (exp0 exp1 ... expn) to get the values (val0 val1 ... valn).
  • If val0 is primitive, e.g., +, do the appropriate built-in computation, resulting in the desired value.
  • If val0 is user-defined, rewrite the function's body, replacing the definition parameters with the values. Evaluate the rewritten body.
Special form define, define-struct, cond; and, or Various, but not shocking. See below for cond, define, define-struct, and finally and/or.

Note that the first part, about placeholders, explains why we see the test output as we do, when we write (times-served empty) = 0. Note that a slightly nicer way to write your test cases could be: (= (times-served empty) 0). (What would print out?)

Note anything familiar? The rules of evaluation are recursive. If you wanted, you could make your own data definitions to represent (your versions of) numbers, placeholders, function-call, and define; then you could use the design recipe, and write a scheme evaluator -- the core of drscheme -- yourself! (After seeing mutually-recursive data structures next week, this is a reasonable week-4 scheme homework.) Elegance speaks for itself!

Note: Over the rest of the semester, we will learn (just) three more special forms. (The formal definition of the corresponding part of C++ or Java requires about dense 30 pages, instead of 1. Those specifications have also been found to contain inconsistencies and errors, which have taken a long time to get revised.)

Digression: the proper use of quotation marks.

The Law of Scheme -- Special Forms