[racket] Using ... in a syntax pattern destroys location information?

From: Carl Eastlund (cce at ccs.neu.edu)
Date: Tue Jun 28 17:52:31 EDT 2011

Danny,

Can you be more specific about what "funkiness" means?  That is, give
us a full program and its output that shows an expected and actual
source location that differ.  Right now there are a few things you
could be referring to.

Carl Eastlund

On Tue, Jun 28, 2011 at 4:51 PM, Danny Yoo <dyoo at cs.wpi.edu> wrote:
> I was working with a few friends, and we came across the following
> behavior: simple usage of the syntax pattern matching system doesn't
> seem to preserve the syntax location of syntax objects under certain
> conditions.
>
>
> Here's an example to demonstrate:
>
> ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
> #lang racket
>
> (define x (datum->syntax #f 'hello (list 'my-source 3 3 18 5)))
> (define y (datum->syntax #f 'world (list 'my-source 3 9 24 5)))
>
> (define a-bigger-syntax #`(module foo racket/base (#%module-begin #,x #,y)))
>
> (define a-reconstructed-syntax
>  (syntax-case a-bigger-syntax ()
>    [(module name language (a-modbeg body ...))
>     #'(module name language (a-modbeg body ...))]))
> ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
>
>
> When we inspect the syntax locations in a-reconstructed-syntax, we see
> funkiness associated with the locations of the body elements.
>
>
> We've isolated the issue down to the use of ...; if we do the
> following, things look slightly better, but the location of the
> 'world' is still messed up.
>
> ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
> (define another-reconstructed-syntax
>  (syntax-case a-bigger-syntax ()
>    [(module name language (a-modbeg . body))
>     #'(module name language (a-modbeg . body))]))
> ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
>
>
> I guess I'm trying to say: I don't understand the behavior of syntax
> and syntax-case, with regards to how they preserve the source
> locations of the matched sub-elements.



Posted on the users mailing list.