The main problem is that you need to attach the 'not-free-identifier=?
property to the syntax object produced by your rename transformer:
(begin-for-syntax
(struct string-box (str)
#:mutable
#:property prop:rename-transformer
(lambda (inst)
(syntax-property
(if (string-box-str inst)
#'string1
#'string2)
'not-free-identifier=?
#t))))
Otherwise, `current-str` is created as an alias to the binding of the
initial result from `(string-box #t)`. That binding alias effectively
overrides rename transformer.
A second problem is that you want `(syntax-e #'value)` instead of just
`#'value`.
At Mon, 14 Dec 2015 15:37:13 -0500, Leif Andersen wrote:
> Hello,
>
> I am trying to use a struct that is both mutable, and has
> prop:rename-transformer, to create a mutable rename transformer. I am
> able to update the value in the struct, and that update gets reflected
> properly when I do `syntax-local-value/immediate`, but
> `syntax-local-value` seems to keep around the previous definition.
>
> Is prop:rename-transformer or syntax-local-value supposed to cache its
> result, or would this be a bug?
>
> My code so far is here: http://pasterack.org/pastes/41342
>
> ```
> #lang racket
>
> (define-syntax string1 "hello")
> (define-syntax string2 "world")
>
> (begin-for-syntax
> (struct string-box (str)
> #:mutable
> #:property prop:rename-transformer
> (lambda (inst)
> (if (string-box-str inst)
> #'string1
> #'string2))))
> (define-syntax (string-lookup stx)
> (syntax-case stx ()
> [(_ id)
> #`'#,(syntax-local-value #'id)]))
> (define-syntax (string-set! stx)
> (syntax-case stx ()
> [(_ box value)
> (begin
> (define-values (x y) (syntax-local-value/immediate #'box))
> (set-string-box-str! x #'value)
> #'(void))]))
>
> (define-syntax current-str (string-box #t))
> (string-lookup current-str)
> (string-set! current-str #f)
> (string-lookup current-str)
> ```
>
> Thank you for your help.
>
> ~Leif Andersen
>
> --
> You received this message because you are subscribed to the Google Groups
> "Racket Developers" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To post to this group, send email to [email protected].
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/racket-dev/CAAVaeEBxrRT1soNDP5xmrJnaYwfc49qUA
> N9P44qEqudggjUmgA%40mail.gmail.com.
> For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups
"Racket Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/racket-dev/566f2ffc.4e09620a.205ee.fffff772SMTPIN_ADDED_MISSING%40gmr-mx.google.com.
For more options, visit https://groups.google.com/d/optout.