[CM] Object systems in S7? (CLOS, MOPs, etc)

Taube, Heinrich K taube at illinois.edu
Sun Feb 14 10:07:57 PST 2021

FWIW The Common Music 2 code base is 100% CLOS.  The Grace code base uses Bil’s record structure to implement its Scheme pattern objects and it works quite well.

C Side...

pattern_tag = s7_make_c_type(s7, "<pattern>");

s7_define_function(s7, "make-pattern", ffi_make_pattern, 14, 0, false, "pattern constructor”);

Scheme Side...

(define-record pattern flags data length datum period value state
  repeat returning counting traversing next mapr cache)

(define (%alloc-pattern)
  ;; flags data length datum period value state limit returning counting traversing next mapr cache
  (make-pattern 0 (list) #f +nad+ #f +nad+ +nad+ most-positive-fixnum #f #:periods #:depth-first
#f #f #f))

(define (initialize-pattern obj data for rep flags len dper getr mapr)
  (pattern-data-set! obj data)
  (pattern-length-set! obj len)
  (pattern-mapr-set! obj mapr)
  (pattern-next-set! obj getr)
  ;; map data to see if it is constant data or has subpatterns
  (let ((con? #t))
    (map-pattern-data (lambda (x) (if (pattern? x) (set! con? #f)))
    (if con? (set! flags (logior flags +constant-data+))))
(define (make-cycle data . args)
  (unless (pair? data) (set! data (list data)))
  (with-optkeys (args for limit)
    (let ((obj (%alloc-pattern))
  (flags 0)
  (len (length data)))
      (initialize-pattern obj (cons data data) for limit
  flags len len next-in-cycle
  (lambda (fn obj)
    (for-each fn (car (pattern-data obj)))))


On Feb 14, 2021, at 10:17 AM, Iain Duncan <iainduncanlists at gmail.com<mailto:iainduncanlists at gmail.com>> wrote:

Oh great, I hadn't looked there yet. Thanks! Is there any particular implementation or resource you based the class system in there on? (ie, place to read more about how you did it)


On Sun, Feb 14, 2021 at 2:33 AM <bil at ccrma.stanford.edu<mailto:bil at ccrma.stanford.edu>> wrote:
stuff.scm has define-class and friends with some examples
in s7test.scm.  It has some similarities to CLOS.

Cmdist mailing list
Cmdist at ccrma.stanford.edu<mailto:Cmdist at ccrma.stanford.edu>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://cm-mail.stanford.edu/pipermail/cmdist/attachments/20210214/0143ab66/attachment.html>

More information about the Cmdist mailing list