;; TODO: rewrite in terms of rnrs records procedural.

(library (srfi-9)
  (export define-record-type)
  (import (rnrs base)
	  (except (slib record) make-record-type)
	  (prefix (only (slib record) make-record-type) slib-))

  (define (make-record-type name field-tags)
    (slib-make-record-type (symbol->string name) field-tags))

;; Excerpted from:

;; SRFI 9 Reference Implementation

; Definition of DEFINE-RECORD-TYPE

(define-syntax define-record-type
  (syntax-rules ()
    ((define-record-type type
       (constructor constructor-tag ...)
       (field-tag accessor . more) ...)
       (define type
         (make-record-type 'type '(field-tag ...)))
       (define constructor
         (record-constructor type '(constructor-tag ...)))
       (define predicate
         (record-predicate type))
       (define-record-field type field-tag accessor . more)

; An auxilliary macro for define field accessors and modifiers.
; This is needed only because modifiers are optional.

(define-syntax define-record-field
  (syntax-rules ()
    ((define-record-field type field-tag accessor)
     (define accessor (record-accessor type 'field-tag)))
    ((define-record-field type field-tag accessor modifier)
       (define accessor (record-accessor type 'field-tag))
       (define modifier (record-modifier type 'field-tag))))))
) ; end srfi-9