[plt-scheme] I don't understand this error message

From: Gregory Woodhouse (gregory.woodhouse at sbcglobal.net)
Date: Sun Jan 22 13:16:54 EST 2006

I'm using the following code (so far) to manage my execution environment


;Create an empty environment
(define (create-empty-env parent)
   (cons (make-hash-table) parent))

;Return enclosing environment
(define (parent-env env)
   (cdr env))

;Return a copy of the environment that points to the same enclosing  
environment
(define (copy-env env)
   (cons (hash-table-copy (car env)) (cdr env)))

;Set a variable
(define (put-symbol-value! symbol value env)
   (hash-table-put! (car env) symbol value))

;Get a variable (use failure thunk to recursively check enclosing  
environment)
(define (get-symbol symbol env)
   (hash-table-get (car env) symbol
                   (lambda () (if (list? env)
                                  (get-symbol (cdr env) symbol)))))


It seems to work fine, but when I try to get the value of a variable  
that hasn't been defined, I get an error message that isn't what I  
expect. (Of course, I do expect an error, just not this one.)

 > (define e1 (create-empty-env '()))
 > (define e2 (create-empty-env '()))
 > (put-symbol-value! 'x 4 e1)
 > (get-symbol 'x e1)
4
 > (get-symbol 'x e2)
. car: expects argument of type <pair>; given x
 >

===
Gregory Woodhouse
gregory.woodhouse at sbcglobal.net

"The most incomprehensible thing about
the world is that it is at all comprehensible."
  --Albert Einstein (1879-1955)





Posted on the users mailing list.