[plt-dev] Default syntax printer
On Mon, Aug 10, 2009 at 6:02 PM, Matthew Flatt<mflatt at cs.utah.edu> wrote:
> 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.
I like this move, but I'd prefer a different interface if we're going
to have customizable printing. I propose a 'current-syntax-printer'
parameter. If someone wants essentially the old behavior, they can
set it to void; for full printing they could use write or
pretty-print; the default could be the error printer (has a built-in
width and uses "..."). I can't imagine using print-syntax-width to
set a different number; if I ever used it, I'd set it to either 0 or
+inf.0. Custom printing provides more interesting flexibility.
--Carl