From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: ludo@gnu.org (Ludovic =?iso-8859-1?Q?Court=E8s?=) Newsgroups: gmane.lisp.guile.devel Subject: Re: Custom printers for SRFI-9 records Date: Thu, 27 May 2010 00:34:15 +0200 Message-ID: <87d3wimgwo.fsf@gnu.org> References: <87typvrdja.fsf@gnu.org> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Trace: dough.gmane.org 1274913280 27284 80.91.229.12 (26 May 2010 22:34:40 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Wed, 26 May 2010 22:34:40 +0000 (UTC) To: guile-devel@gnu.org Original-X-From: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Thu May 27 00:34:35 2010 connect(): No such file or directory Return-path: Envelope-to: guile-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1OHPBK-0001et-Hj for guile-devel@m.gmane.org; Thu, 27 May 2010 00:34:34 +0200 Original-Received: from localhost ([127.0.0.1]:40186 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OHPBJ-0000ew-R6 for guile-devel@m.gmane.org; Wed, 26 May 2010 18:34:33 -0400 Original-Received: from [140.186.70.92] (port=34750 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OHPBE-0000Wg-N6 for guile-devel@gnu.org; Wed, 26 May 2010 18:34:29 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1OHPBD-0000NK-1P for guile-devel@gnu.org; Wed, 26 May 2010 18:34:28 -0400 Original-Received: from lo.gmane.org ([80.91.229.12]:40364) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OHPBC-0000N2-O3 for guile-devel@gnu.org; Wed, 26 May 2010 18:34:27 -0400 Original-Received: from list by lo.gmane.org with local (Exim 4.69) (envelope-from ) id 1OHPBA-0001bb-Oq for guile-devel@gnu.org; Thu, 27 May 2010 00:34:24 +0200 Original-Received: from acces.bordeaux.inria.fr ([193.50.110.5]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Thu, 27 May 2010 00:34:24 +0200 Original-Received: from ludo by acces.bordeaux.inria.fr with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Thu, 27 May 2010 00:34:24 +0200 X-Injected-Via-Gmane: http://gmane.org/ connect(): No such file or directory Original-Lines: 59 Original-X-Complaints-To: usenet@dough.gmane.org X-Gmane-NNTP-Posting-Host: acces.bordeaux.inria.fr X-URL: http://www.fdn.fr/~lcourtes/ X-Revolutionary-Date: 8 Prairial an 218 de la =?iso-8859-1?Q?R=E9volution?= X-PGP-Key-ID: 0xEA52ECF4 X-PGP-Key: http://www.fdn.fr/~lcourtes/ludovic.asc X-PGP-Fingerprint: 83C4 F8E5 10A3 3B4C 5BEA D15D 77DD 95E2 EA52 ECF4 X-OS: x86_64-unknown-linux-gnu User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.2 (gnu/linux) Cancel-Lock: sha1:kD9C92BveqcE+jN7uPuoN1hMywM= X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) X-BeenThere: guile-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Developers list for Guile, the GNU extensibility library" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Errors-To: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.lisp.guile.devel:10381 Archived-At: Hi, No Itisnt writes: > On Tue, May 25, 2010 at 3:56 PM, No Itisnt wrote: >> I agree. Here's a patch that adds (srfi srfi-9 gnu) with >> set-record-printer! and adds a subsection to the SRFI-9 part of the >> manual for it. >> I can go ahead and commit it, if that's OK. This looks good to me. > diff --git a/doc/ref/srfi-modules.texi b/doc/ref/srfi-modules.texi > index 0d192fa..b3f9946 100644 > --- a/doc/ref/srfi-modules.texi > +++ b/doc/ref/srfi-modules.texi > @@ -1922,6 +1922,35 @@ The functions created by @code{define-record-type} are ordinary > top-level @code{define}s. They can be redefined or @code{set!} as > desired, exported from a module, etc. > > +@menu > +* SRFI-9 Custom printers:: Customizing print behavior. > +@end menu > + > +@node SRFI-9 Custom printers > +@subsubsection Custom printers Use @unnumberedsubsubsec instead and no menu. Capitalize like this: “SRFI-9 Custom Printers”. > +You may use @code{set-record-printer!} to customize the default printing > +behavior of records. This is a GUILE extension and is not part of SRFI-9. It is s/GUILE/Guile/ and two spaces after and end-of-sentence period. > +located in the @nicode{(srfi srfi-9 gnu)} module. > + > +@deffn {library syntax} set-record-printer! name thunk Rather use @deffn{Scheme Syntax}, which seems to be the most commonly used form in the manual. > +This example prints the employee's name in brackets, for instance ``@code{[Fred]}''. No need for ``quotes'' here. > +(define (set-record-printer! type thunk) > + (struct-set! type vtable-index-printer thunk)) I’d rather call it ‘set-record-type-printer!’ (it prints records, but it’s the printer of the record type). What do you think? You could add a docstring here. And don’t forget to add srfi-9/gnu.scm to ‘SRFI_SOURCES’ in modules/Makefile.am. Thanks, Ludo’.