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.
The reason this happens makes some intuitive sense (though my
understanding of what happens is not precise enough to really explain
it), but it’s not good enough for what I need.
A hacky solution I’ve tried has been to attach the prefab struct
to a piece of “proxy” syntax as a property, like this:
(define proxy-stx
(syntax-property #'proxy 'prop (prefab-box #'add1)))
Then I can replace the #,(prefab-box #'add1) with the following:
(syntax-property #'#,proxy-stx 'prop)
…and I get #'add1 instead of 'add1. This hack seems to cause problems
when it spans multiple modules, though, as I’m discovering. Is there
some other way I can embed a prefab struct in a piece of syntax
without the syntax objects being lost when it is evaluated as an
expression?