1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-06-15 08:10:17 +02:00

Record printer fixes

* doc/ref/srfi-modules.texi: Fix style

* module/srfi/srfi-9/gnu.scm (set-record-type-printer!): renamed from set-record-printer!
This commit is contained in:
No Itisnt 2010-05-26 21:22:46 -05:00
parent 911b03b20c
commit 167510bc10
2 changed files with 9 additions and 14 deletions

View file

@ -1922,30 +1922,24 @@ 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
@cindex record printer
@unnumberedsubsubsec 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
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} set-record-printer! name thunk
@deffn {Scheme 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.
@end deffn
@noindent
This example prints the employee's name in brackets, for instance ``@code{[Fred]}''.
This example prints the employee's name in brackets, for instance @code{[Fred]}.
@example
(set-record-printer! employee-type
(set-record-type-printer! employee-type
(lambda (record port)
(write-char #\[ port)
(display (get-employee-name record) port)

View file

@ -23,7 +23,8 @@
;;; Code:
(define-module (srfi srfi-9 gnu)
#:export (set-record-printer!))
#:export (set-record-type-printer!))
(define (set-record-printer! type thunk)
(define (set-record-type-printer! type thunk)
"Set a custom printer THUNK for TYPE."
(struct-set! type vtable-index-printer thunk))