[plt-dev] Default syntax printer

From: Matthew Flatt (mflatt at cs.utah.edu)
Date: Mon Aug 10 18:02:45 EDT 2009

At Wed, 5 Aug 2009 15:16:57 -0400, Carl Eastlund wrote:
> Is there any chance we can change the default printer to show the
> syntax->datum of syntax objects?  Instead of #<syntax> in error
> messages, it would be much more helpful to see something like #'(foo
> x) or #<syntax:(foo x)>.  Even the error printer, which cuts off at a
> certain point with "...", would be preferable to the current total
> opacity.

Yes, I should have done that a long time ago.

v4.2.1.6 adds a `print-syntax-width' parameter that defaults to 32,
which means that up to 32 characters are used for printing a syntax
object's datum form within `#<syntax>':

 > #'(+ 1 2)
 #<syntax::3 (+ 1 2)>

 > (syntax-e #'(+ 1 2))
 (#<syntax::24 +> #<syntax::26 1> #<syntax::28 2>)

 > #'((lambda (x) (x x)) (lambda (x) (x x)))
 #<syntax::34 ((lambda (x) (x x)) (lambda (...>

I don't know whether 32 is the right default. I think there are
probably times when I want to see a compact printed form for syntax
objects (especially when there are several in a list, or something like
that), and I bet that 32 is usually enough characters to tell me what
syntax object I'm looking at. Then again, +inf.0 seems like a more
natural default. For now, I've gone with the more conservative default
(with respect to previous versions), but after trying it out, let me
know if you think some else would be better.

Posted on the dev mailing list.