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

From: Matthew Flatt (mflatt at cs.utah.edu)
Date: Mon May 10 12:44:34 EDT 2010

At Mon, 10 May 2010 12:22:24 -0400, Sam Tobin-Hochstadt wrote:
> On Thu, May 6, 2010 at 12:35 PM, Matthew Flatt <mflatt at cs.utah.edu> wrote:
> > I've pushed a partial implementation; the documentation is not yet
> > updated, and the Scribble value printer isn't yet converted.
> This is mostly very nice, but I think the printing for structs with
> custom printers isn't right. It seems that they always print with
> leading quotes, which isn't right for Typed Scheme types, for example.
>  It's especially not right if a custom printer prints nothing:
> > (struct x () #:property prop:custom-write void)
> > (x)
> '
> >
> Note the dangling quote.  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.

In old versions, the only option was essentially "quoted" form, even
though the quote wasn't printed. So, that's why the current default is
to assume that a value can be quoted --- as long as all of its
components (as printed by the custom-print handler) can be quoted.

We could tweak that default to not assume quoting if the value is not a
part of an otherwise quotable enclosing form. That choice risks the
problem that old code won't know about quoting and not generate its own
quote if needed.

We could also say that a value is assumed to be quotable, but that it
is responsible for printing its own quote. I think that's probably
slightly worse than tweaking the default based on whether the value is
enclosed in another.

Meanwhile, the `prop:custom-print-as-constructor' property lets you say
that a value cannot be quoted.

> 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.

Posted on the dev mailing list.