[plt-scheme] identifier binding to undefined identifier

From: Jon Rafkind (workmin at ccs.neu.edu)
Date: Sun Nov 2 18:40:53 EST 2008

The docs say identifier-binding returns #f is the binding is a top-level 
binding but what if there is no binding at all?

;; (define y 2)

(define-syntax (bar stx)
  (syntax-case stx ()
    ((_ id)
     (begin
       (printf "binding at ~a\n" (identifier-binding #'id))
       #'id))))

(define-syntax foo
  (syntax-rules ()
    ((_) (let ((x 1))
           (bar y)))))

(foo)

This program prints "binding at #f" when (define y 2) is uncommented or 
not. What is the rationale for this? It seems more logical to return 
'top-level if the identifier is bound at the top-level.


Posted on the users mailing list.