<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; ">&nbsp;&nbsp; &nbsp;; Define "a" as an alias for the "People" table:</span></div><div><font class="Apple-style-span" face="Monaco">&nbsp;&nbsp; &nbsp;(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">&nbsp;&nbsp; &nbsp;; Use "a" in a query:</font></div><div><font class="Apple-style-span" face="Monaco">&nbsp;&nbsp; &nbsp;(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&nbsp;a syntax property to uniquely mark aliases:</div><div><div><br class="webkit-block-placeholder"></div><div><font class="Apple-style-span" face="Monaco">&nbsp;&nbsp; &nbsp;(define-for-syntax sql-alias-key&nbsp;(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">&nbsp;&nbsp; &nbsp;(define-syntax (define-alias stx)</font></div><div><font class="Apple-style-span" face="Monaco">&nbsp;&nbsp; &nbsp; &nbsp;(syntax-case stx ()</font></div><div><font class="Apple-style-span" face="Monaco">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;[(_ id val)</font></div><div><font class="Apple-style-span" face="Monaco">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; (identifier? #'id)</font></div><div><font class="Apple-style-span" face="Monaco">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; (with-syntax ([id (syntax-property #'id sql-alias-key #t)])</font></div><div><font class="Apple-style-span" face="Monaco">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; #'(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>