public inbox for kawa@sourceware.org
 help / color / mirror / Atom feed
From: Per Bothner <per@bothner.com>
To: Duncan Mak <duncanmak@gmail.com>
Cc: kawa mailing list <kawa@sourceware.org>
Subject: Re: Pretty-printing records
Date: Tue, 01 Jan 2019 21:37:00 -0000	[thread overview]
Message-ID: <e1b00bb2-c3c1-88cb-2b09-97c125146c55@bothner.com> (raw)
In-Reply-To: <CABgWrqpGUdTpeK2eGV3641FXwHsegEa2jxzwfv-N=JYkoj3J7w@mail.gmail.com>

On 1/1/19 12:41 PM, Duncan Mak wrote:
> The new output
> 
>      #|kawa:4|# path2
>      #<<pathname> device: unspecific directory: (absolute usr) name:
> morris type: false version: unspecific>
> 
> Like you wrote, it's not exactly pretty-printing, but at least the
> fields of the record are visible in the REPL now.
> 
> I know that in Scheme48, they have a DEFINE-RECORD-DISCLOSER form, it
> looks like this:
> http://s48.org/1.9.2/manual/manual-Z-H-6.html#node_sec_5.9
> 
> In MIT Scheme, their DEFINE-STRUCTURE form is more complicated, and
> includes a PRINT-PROCEDURE option.
> 
> SRFI 9 records are very close to S48 records, maybe
> DEFINE-RECORD-DISCLOSER is the way to go?

That only helps somewhat. It assumes you want something pretty-printed as if
it were a list, except using curly braces.   One issue is if you want
keywords - you'd want each keyword-value pair to be a logical group
(preferably on the same line), without extra parentheses.

There is also the issue of how to manage and look-up the discloser function.

The MIT-Scheme define-structure with print-procedure is more flexible, as
the procedure takes a port, which means you can do flexible pretty-printing.
However, it seems more complicated to use - and to implement.

The simplest for both user and implementor is to have the Record class
implement Printable.  That would give a nice default output.  Having
the ability to customize the output is nice, but gets into more complicated
design issues.

Kawa does have a framework for type-specific printing customization:
See the standardFormat variable in DisplayFormat.java.  However, there
is no simple hook to use it from Scheme without knowing a lot about how it works.
It would be nice to provide such a Scheme wrapper.
-- 
	--Per Bothner
per@bothner.com   http://per.bothner.com/

      reply	other threads:[~2019-01-01 21:37 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-01-01  2:59 Duncan Mak
2019-01-01  3:33 ` Per Bothner
2019-01-01 20:05   ` Per Bothner
2019-01-01 20:42     ` Duncan Mak
2019-01-01 21:37       ` Per Bothner [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=e1b00bb2-c3c1-88cb-2b09-97c125146c55@bothner.com \
    --to=per@bothner.com \
    --cc=duncanmak@gmail.com \
    --cc=kawa@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).