[CM] Help sought for a macro
Iain Duncan
iainduncanlists at gmail.com
Sat Sep 19 10:34:22 PDT 2020
Hi colleagues, I'm trying to figure out how to build a couple of threading
macros that would be very helpful in Max/MSP for Scheme for Max, but it is
frankly over my head right now. Working it out will be a good exercise but
I figured I would post here in case this is trivial for some macro experts
in S7 and they are willing to share something I can study.
I want to implement something like srfi-197, where it is called "chain".
(but srfi-197 uses syntax-case and syntax-rules)
so from the docs there:
(chain x (a b _)) ; => (a b x)
(chain (a b) (c _ d) (e f _)) ; => (let* ((x (a b)) (x (c x d))) (e f x))
(chain (a) (b _ _) (c _)) ; => (let*-values (((x1 x2) (a)) ((x) (b x1
x2))) (c x))
But what I'd really to make on top of that is a version for allows one to
use this for one liners in Max without inner parens, so something like
this, where the macro is ~>
(x ~> a _ b ~> c _ )
becomes something equivalent of:
(c (a (eval x) b))
Because Scheme for Max will take a max message and treat it as code to be
wrapped in outer parens and then eval'd, this will let people do very
useful things in one short max message (where say $i and $i2 come from
another max message sending to it:
$i1 ~> + 10 _ ~> / $i2 _
If anyone has suggestions or feels like helping that would be amazing.
thanks!
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://cm-mail.stanford.edu/pipermail/cmdist/attachments/20200919/35015780/attachment.html>
More information about the Cmdist
mailing list