[racket] Getting context info from ellipses pattern vars when calling DATUM->SYNTAX

From: D Marshall (dmarshall207 at gmail.com)
Date: Sat Nov 13 17:09:46 EST 2010

Hi,

I'm trying to get a working understanding of macros (I don't
know if I'll every really understand them -- I'm trying).

I understand that DATUM->SYNTAX gets it's context
information from it's first argument.  I have no problems
when using simple (non-ellipses) pattern variables, however,
I haven't been unable to get a strictly "ellipses pattern"
to work in this context (no pun intended).  As a
work-a-round I came up w/ passing in a dummy symbol to use
as the first argument but would like to find out how to do
it the correct way.

First my work-a-round :  (works)

    (define-syntax test-this
      (lambda (x)
        (syntax-case x ()
          [(_ ctx a ...)
             (with-syntax
              ([form    (datum->syntax (syntax ctx)
                           `(+ ,@(syntax->datum (syntax (a ...)))))])
              (syntax form))])))

    (let*-values
      ([(one two three)  (values 10 20 30)])
      (test-this '* one two three))

I've tried this but it does not work :

    (define-syntax test-this
      (lambda (x)
        (syntax-case x ()
          [(_ a ...)
             (with-syntax
              ([form    (datum->syntax (syntax (a ...))
                           `(+ ,@(syntax->datum (syntax (a ...)))))])
              (syntax form))])))

    (let*-values
      ([(one two three)  (values 10 20 30)])
      (test-this one two three))


as it comes back with the error message :

  compile: unbound identifier in module in: one

Any help would be much appreciated.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.racket-lang.org/users/archive/attachments/20101113/961db539/attachment.html>

Posted on the users mailing list.