<div dir="ltr">Thanks Bill, that gives me a bunch more to chew on. <div><br></div><div>As part of my documentation for Scheme For Max, I plan on writing a page "S7 for people coming from Clojure". When I do so I will be sure to check here to make sure I present things accurately. :-)</div><div><br></div><div>iain</div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Sat, Jun 6, 2020 at 7:34 AM <<a href="mailto:bil@ccrma.stanford.edu">bil@ccrma.stanford.edu</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">My understanding of the transactional memory stuff was that it was a way<br>
to simplify multithreaded programs. When I had within-s7 threads, I <br>
found<br>
they were slow because of contention for the heap and whatnot, and<br>
using multiple s7 interpreters instead was faster and simpler (from<br>
s7's point of view, of course). My thought was that thread-global<br>
variables could be handled through a traditional data base -- I think<br>
the libgdbm example in s7.html touches on this.<br>
<br>
The immutable! function sets its argument immutable, so I think<br>
almost anything in s7 can be marked as immutable (you can also<br>
use a setter function). It's not automatic, but you could<br>
obviously make it a local convention:<br>
<br>
(define (make-immutable-vector len)<br>
(immutable! (make-vector len)))<br>
<br>
A lot of the metadata info in clojure is also supported in s7, but<br>
under a different set of names: setter, documentation, signature, <br>
arity,<br>
and funclet for function definition location, argument list and source.<br>
Each function or c-object also has a local let that can<br>
contain arbitrary info under arbitrary names. I haven't<br>
implemented that for sequences, but you could implement it<br>
in scheme by using the sequence's setter function's closure<br>
(a kludge, but it should work).<br>
<br>
;;; a function with user-defined metadata:<br>
(define func<br>
(let ((my-special-info "hi"))<br>
(lambda (x)<br>
(+ x 1))))<br>
<br>
((funclet func) :my-special-info) -> "hi"<br>
<br>
;;; use define-constant to define an immutable function<br>
<br>
;;; a vector with user-defined metadata<br>
(define vct<br>
(let ((v (make-vector 23)))<br>
(set! (setter 'v)<br>
(let ((my-info "ho"))<br>
(lambda (s v)<br>
v)))<br>
(immutable! v)))<br>
<br>
(immutable? vct) -> #t<br>
(vector-set! vct 0 32) -> error: can't vector-set! ... (it is immutable)<br>
((funclet (setter vct)) :my-info) -> "ho"<br>
<br>
I need to look at clojure more closely -- I probably<br>
misunderstand the argot.<br>
<br>
<br>
</blockquote></div>