mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-05-21 12:10:26 +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:
parent
e525e4e499
commit
6942d86409
2 changed files with 6 additions and 8 deletions
|
@ -1930,11 +1930,11 @@ desired, exported from a module, etc.
|
||||||
@subsubsection Custom printers
|
@subsubsection Custom printers
|
||||||
@cindex record printer
|
@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
|
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.
|
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},
|
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
|
and @var{thunk} is a procedure accepting two arguments, the record to print, and
|
||||||
an output port.
|
an output port.
|
||||||
|
@ -1945,7 +1945,7 @@ an output port.
|
||||||
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
|
@example
|
||||||
(define-record-printer employee-type
|
(set-record-printer! employee-type
|
||||||
(lambda (record port)
|
(lambda (record port)
|
||||||
(write-char #\[ port)
|
(write-char #\[ port)
|
||||||
(display (get-employee-name record) port)
|
(display (get-employee-name record) port)
|
||||||
|
|
|
@ -23,9 +23,7 @@
|
||||||
;;; Code:
|
;;; Code:
|
||||||
|
|
||||||
(define-module (srfi srfi-9 gnu)
|
(define-module (srfi srfi-9 gnu)
|
||||||
#:export (define-record-printer))
|
#:export (set-record-printer!))
|
||||||
|
|
||||||
(define-syntax define-record-printer
|
(define (set-record-printer! type thunk)
|
||||||
(syntax-rules ()
|
(struct-set! type vtable-index-printer thunk))
|
||||||
((_ type thunk)
|
|
||||||
(struct-set! type vtable-index-printer thunk))))
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue