From a94469c651ae096b84c9b6389b8278113da00100 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Ludovic=20Court=C3=A8s?= Date: Tue, 7 Dec 2010 20:43:49 +0100 Subject: [PATCH] Add a record type printer for vlists/vhashes. * module/ice-9/vlist.scm (): Add a record type printer. --- module/ice-9/vlist.scm | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/module/ice-9/vlist.scm b/module/ice-9/vlist.scm index d72e6c108..5ea09362c 100644 --- a/module/ice-9/vlist.scm +++ b/module/ice-9/vlist.scm @@ -19,6 +19,7 @@ (define-module (ice-9 vlist) #:use-module (srfi srfi-1) #:use-module (srfi srfi-9) + #:use-module (srfi srfi-9 gnu) #:use-module (srfi srfi-26) #:export (vlist? vlist-cons vlist-head vlist-tail vlist-null? @@ -148,6 +149,21 @@ (base vlist-base) (offset vlist-offset)) +(set-record-type-printer! + (lambda (vl port) + (cond ((vlist-null? vl) + (format port "#")) + ((block-hash-table (vlist-base vl)) + (format port "#" + (object-address vl) + (vhash-fold (lambda (k v r) + (+ 1 r)) + 0 + vl))) + (else + (format port "#" + (vlist->list vl)))))) + (define vlist-null ;; The empty vlist. -- 2.20.1