Re: [racket-users] "deleting" syntax properties and macro expander cons-merging

2018-03-11 Thread Alex Knauth


> On Mar 11, 2018, at 2:31 PM, Matthew Flatt  wrote:
> 
> At Sun, 11 Mar 2018 11:27:06 -0400, Alex Knauth wrote:
>> In the expander code I found this [1]:
>> 
>> (define (syntax-property-remove s key)
>>  (if (hash-ref (syntax-props s) key #f)
>>  (struct-copy syntax s
>>   [props (hash-remove (syntax-props s) key)])
>>  s))
>> 
>> Is there a reason why this is not provided as part of the syntax property 
>> operations?
> 
> I see no problem with adding it - done.

Thank you!

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


Re: [racket-users] "deleting" syntax properties and macro expander cons-merging

2018-03-11 Thread Matthew Flatt
At Sun, 11 Mar 2018 11:27:06 -0400, Alex Knauth wrote:
> In the expander code I found this [1]:
> 
> (define (syntax-property-remove s key)
>   (if (hash-ref (syntax-props s) key #f)
>   (struct-copy syntax s
>[props (hash-remove (syntax-props s) key)])
>   s))
> 
> Is there a reason why this is not provided as part of the syntax property 
> operations?

I see no problem with adding it - done.

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


Re: [racket-users] "deleting" syntax properties and macro expander cons-merging

2018-03-11 Thread Alex Knauth


> On Mar 10, 2018, at 6:46 PM, Alex Knauth  wrote:
> 
> 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? 

In the expander code I found this [1]:

(define (syntax-property-remove s key)
  (if (hash-ref (syntax-props s) key #f)
  (struct-copy syntax s
   [props (hash-remove (syntax-props s) key)])
  s))

Is there a reason why this is not provided as part of the syntax property 
operations?

[1]: 
https://github.com/racket/racket/blob/82b5ec8d18a576fd2768ca0983838c5236f43c3d/racket/src/expander/syntax/property.rkt#L53-L57
 


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