Commits

Moritz Heidkamp committed 6d1d60f

turn protocols into records, no need for coops class

Comments (0)

Files changed (1)

coops-protocols.scm

 (module coops-protocols
 
-(<protocol> define-protocol extend-protocol
+((define-protocol make-protocol) protocol? extend-protocol
  protocol-extenders extend-class class-extends?
  satisfies?)
 
  (import chicken)
  (use srfi-1))
 
-(define-class <protocol> ()
-  ((specs)
-   (extenders initform: '() reader: protocol-extenders)))
+(define-record protocol
+  specs (setter extenders))
 
 (define-syntax define-protocol
   (syntax-rules ()
        (define-generic (spec this))
        ...
        (define name
-         (make <protocol>
-           'specs
-           '((spec this args ...)
-             ...)))))))
+         (make-protocol
+          '((spec this args ...)
+            ...)
+          '()))))))
 
 (define-syntax extend-class
   (syntax-rules ()
         ...)
      (begin
        (begin
-         (set! (slot-value protocol 'extenders)
+         (set! (protocol-extenders protocol)
                (cons class (protocol-extenders protocol)))
          (define-method (spec (this class) args ...) body ...)
          ...)