Hi Iain, Wasn't aware of the chain srfi. Interesting. Since I'm coming more from clojure I guess I'll focus a bit more on the "as->", "->" and "->>". Could try fiddling with these from Monday on and will keep you posted on the process.
The "(x ~> a _ b ~> c _ )" form seems kinda too much though, adding infix notation to the mix On Sat, 19 Sep 2020 at 19:37, Iain Duncan <[email protected]> wrote: > 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! > _______________________________________________ > Cmdist mailing list > [email protected] > https://cm-mail.stanford.edu/mailman/listinfo/cmdist >
_______________________________________________ Cmdist mailing list [email protected] https://cm-mail.stanford.edu/mailman/listinfo/cmdist
