[plt-scheme] syntax/loc for synthesized location data

From: Carl Eastlund (carl.eastlund at gmail.com)
Date: Thu Feb 26 21:19:04 EST 2009

On Thu, Feb 26, 2009 at 8:52 PM, Dave Herman <dherman at ccs.neu.edu> wrote:
> [I tried sending this to plt-dev but it isn't showing up for some reason.]
>
> Is there a reason why the following should fail to attach source location
> information?
>
>> (define loc
>   (datum->syntax #f 'hello (list #f 100 4 4 5)))
>> loc
> #<syntax:100:4>
>> (define stx
>   (syntax/loc loc
>     (list 1 2 3 4 5)))
>> stx
> #<syntax:9:6>

I was able to duplicate your program:

> (define loc (datum->syntax #f 'hello (list #f 100 4 4 5)))
> loc
.#<syntax:100:4>
> (define stx (syntax/loc loc (list 1 2 3 4 5)))
> stx
.#<syntax:6:30>

I then got different behavior by providing a source other than #f:

> (define loc2 (datum->syntax #f 'goodbye (list 'here 100 4 4 5)))
> loc2
.#<syntax:100:4>
> (define stx2 (syntax/loc loc2 (list 5 4 3 2 1)))
> stx2
.#<syntax:100:4>

-- 
Carl Eastlund


Posted on the users mailing list.