<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 <ryanc@ccs.neu.edu>:<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> (syntax-case stx ()<BR> [(wctu form ...)<BR> (syntax-local-introduce<BR> (syntax-local-eval #'(quasisyntax (begin form ...))))]))<BR><BR>Here's an example use:<BR><BR>(begin-for-syntax<BR> (define the-symbol 'apple))<BR><BR>(with-compile-time-unsyntax<BR> (define (f x)<BR> (case x<BR> ((#,the-symbol) 'yes)<BR> (else 'no))))<BR><BR>(f 'apple) ;; => 'yes<BR>(f 'pear) ;; => '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>> Yes. Really it is read-time.<BR>><BR>> In CL every top level expression read-compile-load or simply load if it<BR>> is compiled.<BR>><BR>> So in Racket would be natural to have (for-syntax ...) environment in #.<BR>> I hope, that Racket also read toplevel form, loads it, then reads next<BR>> (not reads all at once, then load first form , second form and so on).<BR>><BR>> Can you invent such read-macro?<BR>><BR>><BR>> Понедельник, 29 июля 2013, 21:44 -04:00 от Sam Tobin-Hochstadt<BR>> <<A href="https://e.mail.ru/messages/sentmsg?compose&To=samth@ccs.neu.edu">samth@ccs.neu.edu</A>>:<BR>><BR>> On Mon, Jul 29, 2013 at 1:53 PM, Vincent St-Amour<BR>> <<A href="https://e.mail.ru/messages/sentmsg?compose&To=stamourv@ccs.neu.edu">stamourv@ccs.neu.edu</A><BR>> <<A href="https://e.mail.ru/messages/sentmsg?compose&To=stamourv@ccs.neu.edu" target=_blank>https://e.mail.ru/messages/sentmsg?compose&To=stamourv@ccs.neu.edu</A>>> wrote:<BR>> > Here's a quick solution:<BR>> ><BR>> > #lang racket<BR>> ><BR>> > (define-syntax-rule (hash-dot e)<BR>> > (let-syntax ([computed-e (lambda (stx) (datum->syntax #'e e))])<BR>> > (computed-e)))<BR>> ><BR>> > (hash-dot (+ 2 3))<BR>> ><BR>><BR>> In CL, #. is read-time, not compile-time, evaluation, so this isn't<BR>> quite the same. It would be easy to create a read-table that enabled<BR>> this, though. You'd have to make some decision about what environment<BR>> the read-time expression sees -- I don't know what CL does here.<BR>><BR>> Sam<BR>><BR>><BR>><BR>> --<BR>> Roman Klochkov<BR>><BR>><BR>><BR>> ____________________<BR>> Racket Users list:<BR>> <A href="http://lists.racket-lang.org/users" target=_blank>http://lists.racket-lang.org/users</A><BR>><BR><BR></DIV><BASE href="https://e.mail.ru/" target=_self></DIV></DIV></DIV></BLOCKQUOTE><BR><BR>-- <BR>Roman Klochkov<BR></BODY></HTML>