record-discloser.scm 465 B

1234567891011121314
  1. ;;; Copyright 2022 Andrew Whatson
  2. (define-module (prescheme record-discloser)
  3. #:use-module (srfi srfi-9 gnu)
  4. #:export (define-record-discloser))
  5. (define (define-record-discloser type discloser)
  6. (set-record-type-printer! type
  7. (lambda (record port)
  8. (let* ((vals (discloser record))
  9. (specs (string-join (make-list (length vals) "~a")))
  10. (template (string-append "{" specs "}")))
  11. (apply format port template vals)))))