C311 Assignment 8 -- Dynamic scope

Due Monday, March 27th, at 8:55 AM

Finish reading EOPL Chapter 5.

Submit via email

  1. Define a <static&dynamic-language> class that extends your <let-language> (in which the parser expands let expressions into calls) such that variables whose names begin with a colon are dynamically bound, while all others are statically bound.

    Examples:

    (let ((x 3)
          (y 4))
      (let ((f (lambda (a) (+ a y)))
    	(y 5))
        (f x)))
    
    ==> 7
    
    (let ((x 3)
          (:y 4))
      (let ((f (lambda (a) (+ a :y)))
    	(:y 5))
        (f x)))
    
    ==> 8
    
    The following procedure may be used to determine if a variable name refers to a dynamic variable.
    (define dynamic-var?
      (lambda (var)
        (char=? #\: 
          (string-ref (symbol->string var) 0))))
    
chaynes@indiana.edu