On Thu, 2009-06-18 at 05:59 +0200, Michele Simionato wrote:
> On Sun, Jun 14, 2009 at 10:18 PM, Abdulaziz Ghuloum<[email protected]> wrote:
> > (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)))))
>
> Why not just
>
> (define (unbound? id)
> (let ([unbound-id (datum->syntax #'dummy-ctxt (syntax->datum id))])
> (free-identifier=? id unbound-id)))
>
> ?
Because #'dummy-ctxt has a lexical context and so any bound identifiers
with a matching lexical context will incorrectly be said to be unbound:
(define-syntax use-unbound
(lambda (stx)
(define (unbound? id)
(let ((unbound-id (datum->syntax #'dummy-ctxt (syntax->datum id))))
(free-identifier=? id unbound-id)))
(syntax-case stx ()
((_ id) (unbound? #'id) #''unbound)
((_ id) #''bound))))
(define x "bound")
(write (use-unbound x)) (newline)
PRINTS=>
unbound
--
: Derick
----------------------------------------------------------------