define-record-and-printer

Trivial macro to define records and appropriate printers

  1. define-record-and-printer
    1. define-record-and-printer
    2. About this egg
      1. Author
      2. Repository
      3. License
      4. Dependencies
      5. Versions
      6. Colophon

define-record-and-printer

[syntax] (define-record-and-printer name slotname) → record

Define a record and a printer that shows the contents of the record as a vector; see define-record.

name
The name of the record
slotname
The name of the slot
(define-syntax
  define-record-and-printer
  (lambda (expression rename compare)
    (match expression
           ((_ record . fields)
            (let ((%define-record (rename 'define-record))
                  (%define-record-printer (rename 'define-record-printer))
                  (%begin (rename 'begin))
                  (%lambda (rename 'lambda))
                  (%write (rename 'write))
                  (%record->vector (rename 'record->vector)))
              `(,%begin
                (,%define-record ,record ,@fields)
                (,%define-record-printer
                 ,record
                 (,%lambda
                  (record out)
                  (,%write (,%record->vector record) out)))))))))

About this egg

Author

Peter Danenberg

Repository

https://github.com/klutometis/define-record-and-printer

License

BSD

Dependencies

Versions

0.1
Version 0.1
0.1.1
Release with docs
0.1.2
Add cock.

Colophon

Documented by cock.