A Song for the Metacircular Evaluator

In case you need any help studying for the midterm/final. Recorded using my MacBook Pro's internal mic, so cut me some slack. All vocals performed by me.

Listen to "To Evaluate" (AAC).

First you type it in a Scheme expression It evaluates, then the answer makes its way back to you.

If a variable was meant check the environment Hope we find a frame, with the variable's name and a value, too.

Oh, can't you see? It's SICP. In CS61A, you do things Scheme's own way!

If the variable's not there We just call Scheme's own error. Otherwise we return, the value we just learned for EVAL to use.

Special forms we have to do by hand QUOTE, IF, LET, DEFINE, SET!, COND, OR, AND BEGIN, and LAMBDA -- they're all done manually Good thing that we get numbers and bools for free You just use the ones provided there by Scheme

(interlude)

Do you want more? This is chapter 4. That was most of EVAL, we need APPLY as well!

If we're left with parens The work just never ends Pass the operator, and the parameters to MC-APPLY

If it's primitive We can be passive Pass it down to Scheme, it'll work like a dream On that we rely

But if it's compound then there's more work to do You have to make a new frame and attach it to the environment in the bubble on the right Make sure to add any parameters in sight

And now there's only one thing left that makes sense You pass the body and environment to eval-sequence The expressions get evaluated one by one Return the last expr's value when we're done Then print the answer back to, back to me!

And that's how it all works Although it has its quirks Now go read the source, and you'll ace this course Scheme is there for you

For a one phrase hint, "read-eval-apply-print" Scheme is there for you

Scheme is there for you Everything typed in Every s-expression Every QUOTE or BEGIN Everything to print Scheme is there for you

Every variable name Every environment frame Every lambda pair Every value there Scheme is there for you

Back to Jordy's home page | Course home page