[racket] Why is syntax-e returning a pair and not a list?

From: Tim Nelson (tbnelson at gmail.com)
Date: Mon May 27 15:06:20 EDT 2013

Dear All,

The documentation for syntax-e says that it may return many different
types, including a syntax-pair, but it doesn't really describe why. Here's
a concrete piece of code:

(define stx
  (with-syntax ([x #'5]
                [(y ...) #'(1 2)])
    (syntax (x y ...))))

(syntax->datum stx) returns a list.

(syntax->list stx) (of course) returns a list, too.

But (syntax-e stx) returns a pair! If I do this:

(define stx2
  (with-syntax ([x #'5]
                [y #'(1 2)])
    (syntax (x y))))

I get a list from syntax-e, but of course the nesting is wrong/different.

So my question is: why a pair?

Best,
- Tim (Running Racket v. 5.3.3)

Posted on the users mailing list.