chickadee » define-record-and-printer

Outdated egg!

This is an egg for CHICKEN 4, the unsupported old release. You're almost certainly looking for the CHICKEN 5 version of this egg, if it exists.

If it does not exist, there may be equivalent functionality provided by another egg; have a look at the egg index. Otherwise, please consider porting this egg to the current version of CHICKEN.

define-record-and-printer

Trivial macro to define records and appropriate printers

define-record-and-printer

(define-record-and-printer name slotname) → recordsyntax

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.
0.1.3
Remove the dependency on setup-helper-cock.
0.1.4
Use hahn.

Colophon

Documented by hahn.

Contents »