[plt-dev] Re: [plt-bug] all/10895: quasiquote printing is buggy, confusing

From: Matthew Flatt (mflatt at cs.utah.edu)
Date: Mon May 10 14:02:48 EDT 2010

At Mon, 10 May 2010 13:46:52 -0400, Sam Tobin-Hochstadt wrote:
> On Mon, May 10, 2010 at 12:44 PM, Matthew Flatt <mflatt at cs.utah.edu> wrote:
> >  It seems there should be a way to make
> >> custom structs print as if they should be quoted, but that shouldn't
> >> be the default.
> >
> > I'm not sure about the default.
> Here's the results of surveying uses of `prop:custom-write' in collects:
> 3 that shouldn't be quoted (1 of them by me)
> 3 that are not expressions, but are printed with () anyway, so should
> probably be made unreadable (all by me)
> 9 unreadable, so it shouldn't be quoted
> - 1 of these should be changed to a non-quoted form, probably (`set')
> 1 that has a pseudo-self-quoting syntax (srfi/63)
> This suggests that no one is writing custom printers that should be
> quoted.  Further, since there's no mechanism for structs to
> automatically extend the read syntax and the behavior of `quote', only
> very rarely will structs be usefully printed in a quoted form.  Both
> of these pieces of evidence suggest to me that quoting is the wrong
> default.

I think the piece/default that's missing is an "unreadable" property.
There's currently no way to say that a custom-write procedure produces
unreadable output, even though the printer otherwise treats unreadable
values specially: It doesn't put a quote in front, although it lets a
unreadable value be quoted if it appears within otherwise quotable

So, how about replacing `prop:custom-print-as-expression' with
`prop:custom-print-mode' whose value is either 'unreadable,
'unquotable, or 'quotable, where the default is effectively

> > > Finally, one more things I noticed when looking at the custom-write
> > > docs: The following expression at the DrRacket repl errors with a
> > > strange error message:
> > >
> > > > #0='#(#0#)
> > > . read: #..= expressions not allowed in read-syntax mode
> > >
> > > This used to be allowed, right?
> >
> > This was allowed prior to v4.0, but not since v4.0.
> The error message is rather confusing - why does it mention `read-syntax'?

The `read' function can accept the input


but `read-syntax' cannot, since no corresponding syntax object can be

I'll make a note to try an improve the error message.

Posted on the dev mailing list.