<div dir="ltr"><br><div class="gmail_extra"><br clear="all"><div>Carl Eastlund</div>
<br><br><div class="gmail_quote">On Wed, Jul 10, 2013 at 11:28 PM, Matthew Flatt <span dir="ltr"><<a href="mailto:mflatt@cs.utah.edu" target="_blank">mflatt@cs.utah.edu</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div class="HOEnZb"><div class="h5">At Wed, 10 Jul 2013 23:15:46 -0400, Ryan Culpepper wrote:<br>
> On 07/10/2013 09:04 PM, Asumu Takikawa wrote:<br>
> > Hi all,<br>
> ><br>
> > I'm currently trying to fix the Typed Racket unit tests. I think I've<br>
> > narrowed down the issue to a certain syntax property for keyword<br>
> > functions.<br>
> ><br>
> > The issue is illustrated by the following example:<br>
> ><br>
> > #lang racket<br>
> ><br>
> > (require racket/file<br>
> > (for-syntax racket/file<br>
> > racket/keyword-transform))<br>
> ><br>
> > ;; the property is #f<br>
> > (begin-for-syntax<br>
> > (displayln<br>
> > (syntax-case (expand-syntax #'(copy-directory/files 1 2)) ()<br>
> > [(let-values (((temp1) _)<br>
> > ((temp2) _))<br>
> > (if _<br>
> > (#%plain-app1 copy-directory/files15 e1 ...)<br>
> > (#%plain-app2 copy-directory/files17 e2 ...)))<br>
> > (syntax-procedure-converted-arguments-property<br>
> #'copy-directory/files15)])))<br>
> ><br>
> > ;; property is syntax<br>
> > (begin-for-syntax<br>
> > (displayln<br>
> > (syntax-case (local-expand #'(copy-directory/files 1 2) 'expression<br>
> null) ()<br>
> > [(let-values (((temp1) _)<br>
> > ((temp2) _))<br>
> > (if _<br>
> > (#%plain-app1 copy-directory/files15 e1 ...)<br>
> > (#%plain-app2 copy-directory/files17 e2 ...)))<br>
> > (syntax-procedure-converted-arguments-property<br>
> #'copy-directory/files15)])))<br>
> ><br>
> > There are two syntax-time computations here. Both are expanding an<br>
> > application of a keyword function (one with local-expand, one with<br>
> > expand) and looking at the resulting syntax.<br>
> ><br>
> > The key point here is that I want to find the property looked up by<br>
> > `syntax-procedure-converted-arguments-property` on an output identifier<br>
> > because Typed Racket needs it to type-check the expansion.<br>
> ><br>
> > Unfortunately, as the comments indicate, only the second piece of code<br>
> > can find the property. The reason appears to be that the property key is<br>
> > actually a private `gensym`ed symbol and the two pieces of code appear<br>
> > to get separate instantiations of the kw.rkt module (perhaps at different<br>
> > phases).<br>
> ><br>
> > To check that, if I modify kw.rkt to use a plain symbol, both of the<br>
> > snippets above return the same property value.<br>
> ><br>
> > Anyone have any idea how I can keep using `expand` but still be able to<br>
> > look up the property?<br>
><br>
> To get information about a phase-0 '#%app' expansion, you need to call<br>
> the phase-1 version of 'syntax-procedure-converted-arguments-property'.<br>
> That's going to require a bit of phase-crossing trickery, because the<br>
> identifier you want to query is a phase-0 (dynamic) value, and you want<br>
> the result as a phase-0 value, but the phase-1 function naturally<br>
> consumes and produces phase-1 values.<br>
><br>
> One solution is to use 'quote-syntax', 'eval', and 'phase1-eval' all<br>
> together. Use 'eval' with 'quote-syntax' to convert the phase-0<br>
> identifier to a phase-1 identifier. Use 'phase1-eval' to run the<br>
> computation at phase 1 and capture the phase-1 result as a phase-0 value<br>
> (also using 'quote-syntax').<br>
<br>
</div></div>I haven't thought about this much, but would it make more sense to move<br>
the property key to a cross-phase persistent module (with a `protected'<br>
provide) in this case?<br></blockquote><div><br></div><div>That came up on IRC. I believe Asumu said the key is an uninterned identifier, meaning it's a stateful value. Right now, cross-phase persistent modules can't store anything stateful other than generative struct types.<br>
<br></div><div>--Carl<br></div></div></div></div>