On Jun 14, 2009, at 10:46 PM, Abdulaziz Ghuloum wrote:

BTW, this is not a 100% correct definition of when-bound, but ...

The more I stare at it, the more it looks correct.
Here's a more self-documenting version of the same code:

(define-syntax when-bound
  (lambda (x)
    (define unbound?
      (let ([empty-ctxt (car (generate-temporaries '(t)))])
        (lambda (id)
          (let ([unbound-id
                 (datum->syntax empty-ctxt (syntax->datum id))])
            (free-identifier=? id unbound-id)))))
    (syntax-case x ()
      [(_ (id) e* ...)
       (if (unbound? #'id)
           #'(begin)
           #'(begin e* ...))])))

Aziz,,,


Reply via email to