From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 44727 invoked by alias); 1 Jan 2019 20:42:17 -0000 Mailing-List: contact kawa-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: kawa-owner@sourceware.org Received: (qmail 44702 invoked by uid 89); 1 Jan 2019 20:42:17 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-1.9 required=5.0 tests=BAYES_00,FREEMAIL_FROM,KAM_SHORT,RCVD_IN_DNSWL_NONE,SPF_PASS autolearn=ham version=3.3.2 spammy=device X-HELO: mail-io1-f53.google.com Received: from mail-io1-f53.google.com (HELO mail-io1-f53.google.com) (209.85.166.53) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 01 Jan 2019 20:42:15 +0000 Received: by mail-io1-f53.google.com with SMTP id v10so23234308ios.13 for ; Tue, 01 Jan 2019 12:42:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=286xzppkk7nbnW9VpvBusoWunwJJRdtR4Svtqp+zX1I=; b=M2nS0wxhMEhyV/O6vfLurgSEgV8HAZg6MXHXrX0Tg6uhU6SChQNLMj+SIGsapxAcDe BCf2vRYJl+3UpRV0AKRCzHdOiwyTlX43pXQRJh5kcdZr7rhhGTlvT8MEkQAk6W+0uOW1 Dg5PYVRIpSGOkT3lQfKcgDGol4SIuldnLeNBRUphWEISP5DPuXACpL2x1kmC5nKYXVRL drGSO1f/l4q42/cB0XpxQwW5ypax4sXbUF1WDaKQ/65RXJAaTbR3tr8TbWNNN2GnbHpt Ce4OiVCZaSifZiXp1VbKv3haVy0PPDu0iTpYUlFflPaSYMn13JfxR0w+yxDafi0EMy5+ 1c/Q== MIME-Version: 1.0 References: <6d13d508-1739-191f-5c40-2a8b24be264f@bothner.com> In-Reply-To: <6d13d508-1739-191f-5c40-2a8b24be264f@bothner.com> From: Duncan Mak Date: Tue, 01 Jan 2019 20:42:00 -0000 Message-ID: Subject: Re: Pretty-printing records To: Per Bothner Cc: kawa mailing list Content-Type: text/plain; charset="UTF-8" X-IsSubscribed: yes X-SW-Source: 2019-q1/txt/msg00006.txt.bz2 Ahh, I just tested out the change. Very cool. The old output: #|kawa:2|# (import (mit-scheme pathname)) #|kawa:3|# (define path2 (->pathname "/usr/morris")) #|kawa:4|# path2 mit-scheme.pathname$pathname@7b53b1ad The new output #|kawa:4|# path2 #< 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? Thanks and happy new year! Duncan. On Tue, Jan 1, 2019 at 3:05 PM Per Bothner wrote: > > On 12/31/18 7:32 PM, Per Bothner wrote: > > Something similar could be done for SRFI-9 records, but it might take some changes > > in how they are implemented, to better support introspection. Using Java > > reflection is possible, though maybe expensive. > > It turned out to be relatively simple to change SRFI-9 records so they > extend kawa.lang.Record. This fixes printing of the resulting records. > > This doesn't accomplish pretty-printing, but that should also be fairly simple. > Probably best by having kawa.lang.Record implement gnu.kawa.format.Printable. > -- > --Per Bothner > per@bothner.com http://per.bothner.com/ -- Duncan.