[plt-scheme] Recognising identifiers bound with a certain macro

From: Dave Gurnell (d.j.gurnell at gmail.com)
Date: Fri Feb 8 08:51:30 EST 2008

Hi all,

I have a macro, "define-alias", that I'm using to define table aliases  
in a Scheme wrapper for SQL:

     ; Define "a" as an alias for the "People" table:
     (define-alias a People)

     ; Use "a" in a query:
     (sql (select #:from a ...))

In my "sql" macro, I'd like to be able to distinguish between  
identifiers bound with "define-alias" and other identifiers bound with  
other forms. My current approach is to use a syntax property to  
uniquely mark aliases:

     (define-for-syntax sql-alias-key (gensym 'sql-alias-key))

     (define-syntax (define-alias stx)
       (syntax-case stx ()
         [(_ id val)
          (identifier? #'id)
          (with-syntax ([id (syntax-property #'id sql-alias-key #t)])
            #'(define id val)))]))

This all seems to do what I want, but I can't work out how to get from  
the identifier in the "sql" macro back to the binding identifier in  
the "define-alias".

Can anyone provide the missing link (or perhaps syntax properties  
aren't the right tool for the job)?

Many thanks,

-- Dave
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.racket-lang.org/users/archive/attachments/20080208/8f684194/attachment.html>

Posted on the users mailing list.