[CM] S7 & graphics with ImGui
bil at ccrma.Stanford.EDU
bil at ccrma.Stanford.EDU
Sun Aug 2 15:24:56 PDT 2020
I think s7's let is very similar to clojure's namespace.
(inlet 'x 1) creates a namespace with 'x bound
to 1, and (eval '(+ x 1) (inlet 'x 1)) is 2. Unless
otherwise specified, the "outlet" is the rootlet, so
to make an instance (so to speak) of the class
(inlet 'x 1), you could:
(let ((class (inlet 'x 1)))
(let ((instance (inlet 'y 2)))
(set! (outlet instance) class)
(with-let instance
(+ x y))))
(let ((instance (inlet 'floor (lambda (x) 3.14))))
(with-let instance (floor 1.5)))
By using openlet, these lets can specialize built-in
functions (see mockery.scm) without having to change
to the instance namespace via with-let:
(let ((instance (inlet 'object->string (lambda (obj . rest) "hi"))))
(openlet instance)
(object->string instance))
The hierarchy is the outlet chain. Locals can be added
with varlet, removed with cutlet, mapped over etc.
Another way to set up the chain is sublet:
(let ((class (inlet 'x 1)))
(with-let (sublet class 'y 2) ; class=outlet + y=2 locally
(+ x y)))
More information about the Cmdist
mailing list