[CM] bit OT, Might be of interest

bil at ccrma.Stanford.EDU bil at ccrma.Stanford.EDU
Sat Jun 6 07:34:17 PDT 2020

My understanding of the transactional memory stuff was that it was a way
to simplify multithreaded programs.  When I had within-s7 threads, I 
they were slow because of contention for the heap and whatnot, and
using multiple s7 interpreters instead was faster and simpler (from
s7's point of view, of course).  My thought was that thread-global
variables could be handled through a traditional data base -- I think
the libgdbm example in s7.html touches on this.

The immutable! function sets its argument immutable, so I think
almost anything in s7 can be marked as immutable (you can also
use a setter function).  It's not automatic, but you could
obviously make it a local convention:

(define (make-immutable-vector len)
   (immutable! (make-vector len)))

A lot of the metadata info in clojure is also supported in s7, but
under a different set of names:  setter, documentation, signature, 
and funclet for function definition location, argument list and source.
Each function or c-object also has a local let that can
contain arbitrary info under arbitrary names.  I haven't
implemented that for sequences, but you could implement it
in scheme by using the sequence's setter function's closure
(a kludge, but it should work).

;;; a function with user-defined metadata:
(define func
   (let ((my-special-info "hi"))
     (lambda (x)
       (+ x 1))))

((funclet func) :my-special-info) -> "hi"

;;; use define-constant to define an immutable function

;;; a vector with user-defined metadata
(define vct
    (let ((v (make-vector 23)))
      (set! (setter 'v)
            (let ((my-info "ho"))
              (lambda (s v)
      (immutable! v)))

(immutable? vct) -> #t
(vector-set! vct 0 32) -> error: can't vector-set! ... (it is immutable)
((funclet (setter vct)) :my-info) -> "ho"

I need to look at clojure more closely -- I probably
misunderstand the argot.

More information about the Cmdist mailing list