Also, I should point out that if I wasn't using module+, I get the
expected output:
"yellow"
"blue"

So I think it is due to the module+ macro pulling up the expression
past the assignment.


(This can be seen with the following code that is missing the module+ modules.)

#lang racket

(require racket/splicing)

(define-syntax (yellow stx) #'"yellow")
(define-syntax (blue stx) #'"blue")

(begin-for-syntax
  (struct stx-box (stx)
    #:mutable
    #:transparent
    #:property prop:rename-transformer
    (lambda (inst)
      (syntax-property (stx-box-stx inst) 'not-free-identifier=? #t))))
(define-syntax (set-stx! stx)
  (syntax-case stx ()
    [(_ box value)
     (begin
       (define-values (x y) (syntax-local-value/immediate #'box))
       (set-stx-box-stx! x #'value)
       #'(void))]))

(define-syntax x-top (stx-box #'yellow))

(splicing-let-syntax ([x (syntax-local-value #'x-top)])
  x)

(set-stx! x-top blue)

(splicing-let-syntax ([x (syntax-local-value #'x-top)])
  x)

~Leif Andersen


On Thu, Dec 17, 2015 at 3:08 PM, Leif Andersen <l...@leifandersen.net> wrote:
> Hello,
>
> I am noticing that if I in the body of splicing-let-syntax I put a
> module+, or anything that lifts with
> syntax-local-lift-module-end-decloration really, The stuff that gets
> lifted out doesn't seem  to match what I would expect it to. I suspect
> this is in part do to using prop:rename-transformer, and mutable
> structs, but I don't want to use a syntax-parameter because I would
> like to parameterize over an identifier.
>
> Here is the code I have:
>
> #lang racket
>
> (require racket/splicing)
>
> (define-syntax (yellow stx) #'"yellow")
> (define-syntax (blue stx) #'"blue")
>
> (begin-for-syntax
>   (struct stx-box (stx)
>     #:mutable
>     #:transparent
>     #:property prop:rename-transformer
>     (lambda (inst)
>       (syntax-property (stx-box-stx inst) 'not-free-identifier=? #t))))
> (define-syntax (set-stx! stx)
>   (syntax-case stx ()
>     [(_ box value)
>      (begin
>        (define-values (x y) (syntax-local-value/immediate #'box))
>        (set-stx-box-stx! x #'value)
>        #'(void))]))
>
> (define-syntax x-top (stx-box #'yellow))
>
> (define-syntax y-top 52)
>
> (splicing-let-syntax ([x (syntax-local-value #'x-top)])
>   (module+ test
>     x))
>
> (set-stx! x-top blue)
>
> (splicing-let-syntax ([x (syntax-local-value #'x-top)])
>   (module+ test
>     x))
>
> When I run it out I get:
> "yellow"
> "yellow"
>
> What I would like to get is:
> "yellow"
> "blue"
>
> Is there any better way to do this, and still have x be an identifier
> that is bound to the correct string?
>
> Thank you very much.
>
> ~Leif Andersen

-- 
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+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to