Re: Identifier equality of identifiers stashed in preserved syntax properties

Ryan Culpepper <[email protected]>
Newsgroups gmane.comp.lang.racket.user,gmane.lisp.scheme.plt
Message-ID <[email protected]>
On 10/25/2016 08:04 PM, Alexis King wrote:
> That makes sense; thank you for your quick reply. It might be
> possible to do something like what you describe, but I do have a
> little more context that makes this sort of tricky. I’m trying to
> not just store identifiers but also store prefab structs containing
> identifiers. The issue I’m running into is that embedding prefab
> structs in syntax objects seems to “flatten” the contained syntax
> objects. For example, if I do something like this:
>
>    (begin-for-syntax
>      (struct prefab-box (val) #:prefab)
>      (syntax-parse
>          (local-expand
>           #`(let-syntax ([x (λ (stx)
>                               (syntax-property #'(void) 'prop
>                                                #,(prefab-box #'add1)))])
>               x)
>           'expression '())
>        #:literals [let-values]
>        [(let-values () (let-values () x))
>         (prefab-box-val (syntax-property #'x 'prop))]))
>
> The result of this is not the syntax #'add1, but the symbol 'add1.

Consider that (eval (list 'quote #'+)) also evaluates to a symbol, for 
about the same reason.

Try local-expanding either of these terms instead:

   #`(let-syntax ([x (λ (stx)
                       (syntax-property #'(void) 'prop
                                        (prefab-box #'add1)))])
       x)

or

   #`(let-syntax ([x (λ (stx)
                        #'#,(syntax-property #'(void) 'prop
                                             (prefab-box #'add1)))])
        x)

and the box will have an identifier in it.

Ryan

-- 
You received this message because you are subscribed to the Google Groups "Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to racket-users+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/[email protected]
For more options, visit https://groups.google.com/d/optout.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.