[racket-dev] expand, local-expand, and syntax-procedure-converted-arguments-property

From: Eric Dobson (eric.n.dobson at gmail.com)
Date: Wed Jul 10 21:35:03 EDT 2013

I'm not sure about the exact problem. But I have some work for the TR
unit tests that make it use a saner way of running the tests, and it
allows for the TR syntax properties to be gensyms. It will likely be a
week or two until they are in HEAD (tons of commits that need to be
cleaned up and reviewed) but I can push to github tonight and let you
see if they fix your issue.

On Wed, Jul 10, 2013 at 6:04 PM, Asumu Takikawa <asumu at ccs.neu.edu> wrote:
> Hi all,
>
> I'm currently trying to fix the Typed Racket unit tests. I think I've
> narrowed down the issue to a certain syntax property for keyword
> functions.
>
> The issue is illustrated by the following example:
>
>   #lang racket
>
>   (require racket/file
>            (for-syntax racket/file
>                        racket/keyword-transform))
>
>   ;; the property is #f
>   (begin-for-syntax
>    (displayln
>      (syntax-case (expand-syntax #'(copy-directory/files 1 2)) ()
>        [(let-values (((temp1) _)
>                      ((temp2) _))
>           (if _
>               (#%plain-app1 copy-directory/files15 e1 ...)
>               (#%plain-app2 copy-directory/files17 e2 ...)))
>         (syntax-procedure-converted-arguments-property #'copy-directory/files15)])))
>
>   ;; property is syntax
>   (begin-for-syntax
>    (displayln
>      (syntax-case (local-expand #'(copy-directory/files 1 2) 'expression null) ()
>        [(let-values (((temp1) _)
>                      ((temp2) _))
>           (if _
>               (#%plain-app1 copy-directory/files15 e1 ...)
>               (#%plain-app2 copy-directory/files17 e2 ...)))
>         (syntax-procedure-converted-arguments-property #'copy-directory/files15)])))
>
> There are two syntax-time computations here. Both are expanding an
> application of a keyword function (one with local-expand, one with
> expand) and looking at the resulting syntax.
>
> The key point here is that I want to find the property looked up by
> `syntax-procedure-converted-arguments-property` on an output identifier
> because Typed Racket needs it to type-check the expansion.
>
> Unfortunately, as the comments indicate, only the second piece of code
> can find the property. The reason appears to be that the property key is
> actually a private `gensym`ed symbol and the two pieces of code appear
> to get separate instantiations of the kw.rkt module (perhaps at different
> phases).
>
> To check that, if I modify kw.rkt to use a plain symbol, both of the
> snippets above return the same property value.
>
> Anyone have any idea how I can keep using `expand` but still be able to
> look up the property?
>
> Cheers,
> Asumu
> _________________________
>   Racket Developers list:
>   http://lists.racket-lang.org/dev

Posted on the dev mailing list.