[plt-scheme] Introducing an Identifier into the Lexical Context of a Macro Cal l

From: Williams, M. Douglas (M.DOUGLAS.WILLIAMS at saic.com)
Date: Tue Oct 12 16:51:49 EDT 2004

The PLT Scheme Reference Manual contains the following example in section


Another reason to use syntax-case is to implement ``non-hygienic'' macros
that introduce capturing identifiers: 

(define-syntax (if-it stx)
  (syntax-case stx ()
    [(src-if-it test then else)
     (syntax-case (datum->syntax-object (syntax src-if-it) 'it) ()
       [it (syntax (let ([it test]) (if it then else)))])])))
(if-it (memq 'b '(a b c)) it 'nope) ; => '(b c)


Is this the best way to introduce an identifier ('it' in this case) into the
lexical context of the macro's use? 

Posted on the users mailing list.