1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-05-20 11:40:18 +02:00

* doc/ref/srfi-modules.texi:

* module/srfi/srfi-9/gnu.scm: rename `define-record-printer' to
  `set-record-printer!' to reflect the fact that the printer is set at runtime
This commit is contained in:
No Itisnt 2010-05-25 15:53:24 -05:00
parent e525e4e499
commit 6942d86409
2 changed files with 6 additions and 8 deletions

View file

@ -1930,11 +1930,11 @@ desired, exported from a module, etc.
@subsubsection Custom printers
@cindex record printer
You may use @code{define-record-printer} to customize the default printing
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
located in the @nicode{(srfi srfi-9 gnu)} module.
@deffn {library syntax} define-record-printer name thunk
@deffn {library syntax} set-record-printer! name thunk
Where @var{type} corresponds to the first argument of @code{define-record-type},
and @var{thunk} is a procedure accepting two arguments, the record to print, and
an output port.
@ -1945,7 +1945,7 @@ an output port.
This example prints the employee's name in brackets, for instance ``@code{[Fred]}''.
@example
(define-record-printer employee-type
(set-record-printer! employee-type
(lambda (record port)
(write-char #\[ port)
(display (get-employee-name record) port)

View file

@ -23,9 +23,7 @@
;;; Code:
(define-module (srfi srfi-9 gnu)
#:export (define-record-printer))
#:export (set-record-printer!))
(define-syntax define-record-printer
(syntax-rules ()
((_ type thunk)
(struct-set! type vtable-index-printer thunk))))
(define (set-record-printer! type thunk)
(struct-set! type vtable-index-printer thunk))