[racket] copy syntax properties

From: Ryan Culpepper (ryan at cs.utah.edu)
Date: Wed Feb 15 15:49:38 EST 2012

On 02/15/2012 01:28 PM, Jon Rafkind wrote:
> `datum->syntax' does not copy syntax properties from the 4th
> parameter to the new syntax object if the 2nd parameter is already a
> syntax object. What is the reasoning for this? Lexical context and
> source location are taken from the 1st and 3rd arguments so it seems
> inconsistent for syntax properties not to act the same way. I don't
> really have an opinion as to whether the new syntax object should
> combine syntax properties from the 2nd and 4th argument or if only
> the properties from the 4th should be used.

'datum->syntax' always returns the second argument unchanged if it is 
already a syntax object. The handling of properties is no different from 
the handling of lexical context or source location.

> Perhaps the API for `datum->syntax' could change slightly so that a
> list of syntax objects can be used to provide syntax properties.
>
> (datum->syntax lexical original source (list a b c)) ;; would create a new syntax object with syntax properties from 'a', 'b', and 'c'.
>
> This way the original syntax object can be put into the list to
> retain its properties.
>
> (datum->syntax lexical original source (list original a b c))

Have you looked at 'syntax-track-origin'? Perhaps it handles the 
situation you have.

Ryan

Posted on the users mailing list.