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

From: Robby Findler (robby at cs.uchicago.edu)
Date: Fri Feb 8 10:46:44 EST 2008

syntax-local-value?

Robby

On Feb 8, 2008 7:51 AM, Dave Gurnell <d.j.gurnell at gmail.com> wrote:
> 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
> _________________________________________________
>   For list-related administrative tasks:
>   http://list.cs.brown.edu/mailman/listinfo/plt-scheme
>
>


Posted on the users mailing list.