[plt-dev] Default syntax printer
On Tue, Aug 11, 2009 at 8:58 AM, Matthew Flatt<mflatt at cs.utah.edu> wrote:
> At Mon, 10 Aug 2009 18:45:54 -0400, Carl Eastlund wrote:
>> On Mon, Aug 10, 2009 at 6:02 PM, Matthew Flatt<mflatt at cs.utah.edu> wrote:
>> >
>> > 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.
>
> The `pretty-print' library already supports custom printing for all
> values, not just syntax objects, right? Is there something special
> about syntax objects that merits more general built-in treatment?
On reflection, not really. The width values of 0, +inf.0, and some
arbitrary default in between cover the meaningful points in a default
datum-printing spectrum. Thanks for the feature! Carry on, nothing
to see here. ;)
--Carl