[plt-scheme] macros utilizing syntax parameters

From: Eli Barzilay (eli at barzilay.org)
Date: Thu Mar 5 00:38:59 EST 2009

On Mar  5, David T. Pierson wrote:
> Hi all,
> 
> I created some macros which utilize a syntax parameter.  I thought it
> might be useful as an example for others.  I would also like criticism
> if there is a better way to do what I wanted.  (I'm guessing there is.)

You don't need to use `syntax-parameter-value' if you bind the syntax
parameter to a transformer.  Something like:

  (define-syntax-parameter enclosing-workspace
    (lambda (stx)
      (syntax-case stx ()
        [(_ . xs) #'('(workspace . the-world) . xs)]
        [_ (identifier? stx) #''(workspace . the-world)])))

  (define-syntax (define-work stx)
    use it simply as #'(blah enclosing-workspace blah)
    )

  (define-syntax (workspace stx)
    set it with
    (splicing-syntax-parameterize ([enclosing-workspace
                                    (make-rename-transformer #'name)])
       blah ... )
    )

-- 
          ((lambda (x) (x x)) (lambda (x) (x x)))          Eli Barzilay:
                  http://www.barzilay.org/                 Maze is Life!


Posted on the users mailing list.