The macro expander merges syntax properties between the input of a macro and 
the output of a macro using `cons`. That means that if there is an 
identity-macro call like this:

(identity-macro x)

where both `x` and `(identity-macro x)` have the property `'prop = 5`, the 
final result has the property `'prop = (cons 5 5)`.

To avoid this merging, I would like to "delete" the `'prop` property on the 
`x`. According to the docs for syntax property, it returns #false if no value 
is associated with the key. So it seems like the way to "delete" it is to set 
it to #false.

However, this method of "deleting" doesn't get rid of the merging. Instead I 
get `'prop = (cons #false 5)`. Is there a better way of deleting properties? 

How do I get rid of this merging? Here's my attempt:

#lang racket

(require syntax/parse/define)

(define-simple-macro (id-macro x) x)

(define-syntax-parser get-prop
  [(_ x)
   #`'#,(syntax-property (local-expand #'x 'expression '()) 'prop)])

(define-syntax set-up
  (λ (stx)
    (syntax-property
     #`(id-macro #,(syntax-property #'(void) 'prop #f))
     'prop
     5)))

(get-prop (set-up))
; output: (cons #f 5)

Alex Knauth

-- 
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