<html><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; ">Hi all,<div><br></div><div>I have a macro, "define-alias", that I'm using to define table aliases in a Scheme wrapper for SQL:</div><div><br class="webkit-block-placeholder"></div><div><span class="Apple-style-span" style="font-family: Monaco; "> ; Define "a" as an alias for the "People" table:</span></div><div><font class="Apple-style-span" face="Monaco"> (define-alias a People)</font></div><div><font class="Apple-style-span" face="Monaco"><br></font></div><div><font class="Apple-style-span" face="Monaco"> ; Use "a" in a query:</font></div><div><font class="Apple-style-span" face="Monaco"> (sql (select #:from a ...))</font></div><div><br class="webkit-block-placeholder"></div><div>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:</div><div><div><br class="webkit-block-placeholder"></div><div><font class="Apple-style-span" face="Monaco"> (define-for-syntax sql-alias-key (gensym 'sql-alias-key))</font></div><div><font class="Apple-style-span" face="Monaco"><br class="webkit-block-placeholder"></font></div></div><div><div><font class="Apple-style-span" face="Monaco"> (define-syntax (define-alias stx)</font></div><div><font class="Apple-style-span" face="Monaco"> (syntax-case stx ()</font></div><div><font class="Apple-style-span" face="Monaco"> [(_ id val)</font></div><div><font class="Apple-style-span" face="Monaco"> (identifier? #'id)</font></div><div><font class="Apple-style-span" face="Monaco"> (with-syntax ([id (syntax-property #'id sql-alias-key #t)])</font></div><div><font class="Apple-style-span" face="Monaco"> #'(define id val)))]))</font></div><div><br class="webkit-block-placeholder"></div><div>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".</div><div><br class="webkit-block-placeholder"></div><div>Can anyone provide the missing link (or perhaps syntax properties aren't the right tool for the job)?</div><div><br class="webkit-block-placeholder"></div><div>Many thanks,</div><div><br class="webkit-block-placeholder"></div><div>-- Dave</div></div></body></html>