<HTML><BODY>Great! Thank you! <BR><BR>(with- ...) is the best approach for such in-place substitutions. I missed this opportunity.<BR><BR>Вторник, 30 июля 2013, 0:40 -04:00 от Ryan Culpepper &lt;ryanc@ccs.neu.edu&gt;:<BR>
<BLOCKQUOTE style="BORDER-LEFT: #0857a6 1px solid; PADDING-BOTTOM: 0px; MARGIN: 10px; PADDING-LEFT: 10px; PADDING-RIGHT: 0px; PADDING-TOP: 0px" class=mailru-blockquote>
<DIV>
<DIV class="js-helper js-readmsg-msg">
<STYLE type=text/css></STYLE>

<DIV id=style_13751592230000000019 class=mr_read__body><BASE href="https://e.mail.ru/" target=_self>
<DIV id=style_13751592230000000019_BODY>I don't think read-time computation is the right approach for Racket. <BR>Here's a compile/expand-time alternative that lets you use unsyntax as a <BR>compile-time escape.<BR><BR>(require (for-syntax racket/syntax))<BR><BR>(define-syntax (with-compile-time-unsyntax stx)<BR>&nbsp;&nbsp;&nbsp;(syntax-case stx ()<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;[(wctu form ...)<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(syntax-local-introduce<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(syntax-local-eval #'(quasisyntax (begin form ...))))]))<BR><BR>Here's an example use:<BR><BR>(begin-for-syntax<BR>&nbsp;&nbsp;&nbsp;(define the-symbol 'apple))<BR><BR>(with-compile-time-unsyntax<BR>&nbsp;&nbsp;(define (f x)<BR>&nbsp;&nbsp;&nbsp;&nbsp;(case x<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;((#,the-symbol) 'yes)<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(else 'no))))<BR><BR>(f 'apple) ;; =&gt; 'yes<BR>(f 'pear) ;; =&gt; 'no<BR><BR>If you wanted, you could make a custom language (see #%module-begin) <BR>that implicitly wrapped the whole module body with <BR>with-compile-time-unsyntax automatically.<BR><BR>You might find it difficult to use quasisyntax and unsyntax within such <BR>a module. I haven't tried it or thought through how it would interact <BR>with quasisyntax "levels". You could of course implement your own <BR>quasisyntax-like form with a different escape binding.<BR><BR>Ryan<BR><BR><BR>On 07/29/2013 10:07 PM, Roman Klochkov wrote:<BR>&gt; Yes. Really it is read-time.<BR>&gt;<BR>&gt; In CL every top level expression read-compile-load or simply load if it<BR>&gt; is compiled.<BR>&gt;<BR>&gt; So in Racket would be natural to have (for-syntax ...) environment in #.<BR>&gt; I hope, that Racket also read toplevel form, loads it, then reads next<BR>&gt; (not reads all at once, then load first form , second form and so on).<BR>&gt;<BR>&gt; Can you invent such read-macro?<BR>&gt;<BR>&gt;<BR>&gt; Понедельник, 29 июля 2013, 21:44 -04:00 от Sam Tobin-Hochstadt<BR>&gt; &lt;<A href="https://e.mail.ru/messages/sentmsg?compose&amp;To=samth@ccs.neu.edu">samth@ccs.neu.edu</A>&gt;:<BR>&gt;<BR>&gt; On Mon, Jul 29, 2013 at 1:53 PM, Vincent St-Amour<BR>&gt; &lt;<A href="https://e.mail.ru/messages/sentmsg?compose&amp;To=stamourv@ccs.neu.edu">stamourv@ccs.neu.edu</A><BR>&gt; &lt;<A href="https://e.mail.ru/messages/sentmsg?compose&amp;To=stamourv@ccs.neu.edu" target=_blank>https://e.mail.ru/messages/sentmsg?compose&amp;To=stamourv@ccs.neu.edu</A>&gt;&gt; wrote:<BR>&gt; &gt; Here's a quick solution:<BR>&gt; &gt;<BR>&gt; &gt; #lang racket<BR>&gt; &gt;<BR>&gt; &gt; (define-syntax-rule (hash-dot e)<BR>&gt; &gt; (let-syntax ([computed-e (lambda (stx) (datum-&gt;syntax #'e e))])<BR>&gt; &gt; (computed-e)))<BR>&gt; &gt;<BR>&gt; &gt; (hash-dot (+ 2 3))<BR>&gt; &gt;<BR>&gt;<BR>&gt; In CL, #. is read-time, not compile-time, evaluation, so this isn't<BR>&gt; quite the same. It would be easy to create a read-table that enabled<BR>&gt; this, though. You'd have to make some decision about what environment<BR>&gt; the read-time expression sees -- I don't know what CL does here.<BR>&gt;<BR>&gt; Sam<BR>&gt;<BR>&gt;<BR>&gt;<BR>&gt; --<BR>&gt; Roman Klochkov<BR>&gt;<BR>&gt;<BR>&gt;<BR>&gt; ____________________<BR>&gt; Racket Users list:<BR>&gt; <A href="http://lists.racket-lang.org/users" target=_blank>http://lists.racket-lang.org/users</A><BR>&gt;<BR><BR></DIV><BASE href="https://e.mail.ru/" target=_self></DIV></DIV></DIV></BLOCKQUOTE><BR><BR>-- <BR>Roman Klochkov<BR></BODY></HTML>