CS 61 A - Rules for Environment Diagrams Remember: The...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
Rules for Environment Diagrams Remember: The purpose of drawing environment diagrams is to visualize how Scheme evaluates expres- sions. Preparational work: Start by drawing the Global Environment, set it as your Current Environment. The Golden Rules: 1. Calling a lambda procedure makes frames , pointing to the right bubble of the lambda . 2. Making a lambda procedure makes 2 bubbles , the left holding information and the right pointing to the current frame. The Complete Rules: 1. If the expression is a constant , self-evaluate. There is no need to change anything. 2. If the expression is a symbol , find the binding in Current Environment. If it’s not found, go to the environment that the current environment points to and try to and it there. Repeat process until the binding is found. Error if no binding found in the Global Environment. 3. If the expression is a procedure call then: (a) If the procedure being called is a lambda procedure , follow these lambda-proc call rules: i. Evaluate the arguments by recursively applying these same rules
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 08/14/2010 for the course EECS 61A taught by Professor Harvey during the Summer '08 term at University of California, Berkeley.

Ask a homework question - tutors are online