|
Projects
Spring 2012 Older Courses Fall 2011 Spring 2011 Fall 2010 Spring 2010 Fall 2009 Spring 2009
Fall 2008
Spring 2008
Fall 2007 HOWTOs |
SchemeRulesOfEvaluationMost of the below is copied verbatim from the SICP text, http://mitpress.mit.edu/sicp/full-text/book/book-Z-H-10.html. Elements of Programming
CombinationsTo evaluate a combination, do the following:
Even this simple rule illustrates some important points about processes in general. First, observe that the first step dictates that in order to accomplish the evaluation process for a combination we must first perform the evaluation process on each element of the combination. Thus, the evaluation rule is recursive in nature; that is, it includes, as one of its steps, the need to invoke the rule itself.
PrimitivesWe take care of the primitive cases by stipulating that
We may regard the second rule as a special case of the third one by stipulating that symbols such as + and * are also included in the global environment, and are associated with the sequences of machine instructions that are their values.
The Substitution Model for Procedure ApplicationWe can assume that the mechanism for applying primitive procedures to arguments is built into the interpreter. For compound procedures, the application process is as follows:
Special FormsExceptions to the general evaluation rule are called special forms.
For instance, evaluating (define x 3) does not apply define to two arguments, one of which is the value of the symbol x and the other of which is 3, since the purpose of the define is precisely to associate x with a value. (That is, (define x 3) is not a combination.)
|