[CM] need macro help!
bil at ccrma.Stanford.EDU
bil at ccrma.Stanford.EDU
Wed Sep 8 10:09:07 PDT 2021
I think the "sexp" argument to map is just the
macro argument name 'sexp, so map can't figure
out what to do, and asks make-iterator to do
something (hence the make-iterator error). I
would write the macro:
(define-macro (run-expr sexp)
`(eval (map
(lambda(token)
(if (and (symbol? token)
(eq? ((symbol->string token) 0) #\%))
`(s4m-expr-inputs ,(string->number (substring (symbol->string token)
1)))
token))
,sexp))
so (s4m-run-expr "(+ %1 %2 %3)") returns 66.
If you omit the eval (to see what code is being generated),
(s4m-run-expr "(+ %1 %2 %3)")
returns
(+ (s4m-expr-inputs 1) (s4m-expr-inputs 2) (s4m-expr-inputs 3))
More information about the Cmdist
mailing list