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

Iain Duncan iainduncanlists at gmail.com
Sun Feb 14 11:38:17 PST 2021


Fantastic, thanks Rick! I continue to be so happy I chose S7 for this
project. Being able to build on the Common Music work is great. :-)

On Sun, Feb 14, 2021 at 10:08 AM Taube, Heinrich K <taube at illinois.edu>
wrote:

> 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)))
>       obj)
>     (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)))))
>       obj)))
>
> [...]
>
>
> On Feb 14, 2021, at 10:17 AM, Iain Duncan <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)
>
> iain
>
>
>
>
>
> On Sun, Feb 14, 2021 at 2:33 AM <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
>
> https://urldefense.com/v3/__https://cm-mail.stanford.edu/mailman/listinfo/cmdist__;!!DZ3fjg!vlx95wjWmKfGndRV-oOKnf1WnD1TzGmD7FIKM6HTtoIAyd5rLoZ3G8sO8ulQhA$
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://cm-mail.stanford.edu/pipermail/cmdist/attachments/20210214/e6a323e4/attachment.html>


More information about the Cmdist mailing list