[racket] How does free-identifier=? and bound-identifier=?works?
Your code also returne (#t #t)
Also see Ryan Culpepper's email.
Jos
> -----Original Message-----
> From: users-bounces at racket-lang.org
> [mailto:users-bounces at racket-lang.org] On Behalf Of Marco Maggi
> Sent: 10 April 2011 13:23
> To: Veer
> Cc: users at racket-lang.org
> Subject: Re: [racket] How does free-identifier=? and
> bound-identifier=?works?
>
> Veer wrote:
> > I am unable to understand how free-identifier=? and
> > bound-identifier=? works?
> [...]
> > When I use them ,they both produces #t .
>
> You are misunderstanding the meaning of the function names;
> you may try to read [1] which is an annotated section from
> the R6RS standard.
>
> However, your true misunderstanding is to think that
> identifiers in the input form of a macro transformer have a
> "meaning", for example LET is a binding syntax; they have
> not: identifiers in an input form are just identifiers, they
> do not affect the binding of other identifiers. In your
> example:
>
> (check (lambda (x y) (let ([x 2]) x)))
>
> the identifiers LAMBDA and LET in the input form of the use
> of CHECK are "just identifiers", they do not influence X in
> any way; only if you put into the output form of CHECK they
> may behave like the syntaxes of the language (if they are
> in the correct position).
>
> Also notice that your CHECK macro (as I understand it)
> does not do what you want to do; to do what you want to do
> you should (notice the use of #` and #,):
>
> #!r6rs
> (import (rnrs))
>
> (define-syntax check
> (lambda (stx)
> (syntax-case stx (lambda let)
> [(_ (lambda (x y ...) (let ([a b]) c)))
> #`(values #,(free-identifier=? #'x #'c)
> #,(bound-identifier=? #'x #'c))])))
>
> (let-values (((r1 r2)
> (check (lambda (x y) (let ([x 2]) x)))))
> (write (list r1 r2))
> (newline))
>
> HTH
>
> [1]
> <http://marcomaggi.github.com/docs/nausicaa.html/stdlib-syntax
_002dcase-identifier.html>
>
> P.S. It takes time understand this stuff; also, some people
> think that FREE-IDENTIFIER=? and BOUND-IDENTIFIER=? are an
> unfortunate choice of names, which induces misunderstanding.
> --
> Marco Maggi
> _________________________________________________
> For list-related administrative tasks:
> http://lists.racket-lang.org/listinfo/users