[racket] syntax-e vs syntax->list

From: Matthew Flatt (mflatt at cs.utah.edu)
Date: Fri Aug 15 05:33:01 EDT 2014

Yes, the printer oversimplifies in that sense. It simplifies in the
obvious way of not printing lexical context, but it turns out that it
also simplifies by neglecting the difference between a plain list and a
sequence of pairs that ends in a syntax-object list.

At Fri, 15 Aug 2014 13:03:27 +0400, Roman Klochkov wrote:
> I thought, that #'(1 . (2)) == #'(1 2) as '(1 . (2)) == '(1 2)
> 
> And Racket printer thinks same:
> 
> > #'(1 . (2))
> #<syntax:19:4 (1 2)>
> Fri, 15 Aug 2014 07:13:39 +0100 от Matthew Flatt <mflatt at cs.utah.edu>:
> >At Fri, 15 Aug 2014 09:55:11 +0400, Roman Klochkov wrote:
> >>  What is the difference?
> >> 
> >> > (let ([stx #'(1 (+ 3 4) 5 6)]) (equal? (syntax->list stx) (syntax-e stx)))
> >> #t Or syntax->list == (lambda (x) (let ([res (syntax-e x)]) (if (list? x) x 
> >> #f))) ?
> >
> >You need a `.` to expose the difference:
> >
> > > (syntax-e #'(1 . (2)))
> > '(#<syntax::35 1> . #<syntax::39 (2)>)
> >
> > > (syntax->list #'(1 . (2)))
> > '(#<syntax::62 1> #<syntax::67 2>)
> >
> 
> 
> -- 
> Roman Klochkov
> ____________________
>   Racket Users list:
>   http://lists.racket-lang.org/users


Posted on the users mailing list.