[plt-scheme] macro questions

From: Felix Klock's PLT scheme proxy (pltscheme at pnkfx.org)
Date: Sat Jun 5 15:43:06 EDT 2004


> ; 2) Am I misunderstanding the whats bound on the right-hand side of a
> ; define-syntax? E.g. in the this modules 'require-for-syntax' doesn't
> ; work, but 'require' does.
> (module boolean-if-simple mzscheme
>   (provide (all-defined))
>   (require-for-syntax (lib "match.ss"))
>   ; (require (lib "match.ss"))
>   (define-syntax (bif stx)
>     (syntax-case stx ()
>      [(_ if-stx then-exp else-exp)
>       (syntax
>        (match if-stx [#t then-exp] [#f else-exp]))])))
> (require boolean-if-simple)
> (bif #t 'true 'false)

I think you're misunderstanding the purpose of REQUIRE-FOR-SYNTAX.

REQUIRE-FOR-SYNTAX is meant to import library code that is used by 
transformers; not necessarily by the syntax objects that transformers 

So, in your example above, the only reason one would do 
(require-for-syntax (lib "match.ss"))
is to write code like:

(define-syntax (foo stx)
   (syntax-case stx ()
      (match something
         [('a-pattern) (syntax ...)]
         [else (syntax ...)]))

If all you want to do is refer to match WITHIN the syntax objects you 
create, then you really want just REQUIRE, not REQUIRE-FOR-SYNTAX


"A good extension language lowers your
  code's hacktivation energy."  -guile manual

Posted on the users mailing list.