Environment and Variable Evaluation

A binding list or execution environment is an association list in which each element is a cons of a variable name and its value: ((x . 3) (y . 4) ...)


(define (m-value var env)
  (let ((pair (assoc var env)))
    (if pair
        (cdr pair)
        (m-error "Unbound variable " var)) ))

(define (m-bind formalargs actualargs alist) (if (null? formalargs) (if (null? actualargs) alist (m-error "Too many args " actualargs) ) (if (null? actualargs) (m-error "Not enough args " actualargs) (m-bind (cdr formalargs) (cdr actualargs) (cons (cons (car formalargs) (car actualargs)) alist)) ) ))

Contents    Page-10    Prev    Next    Page+10    Index