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))

_______________________________________________
Cmdist mailing list
[email protected]
https://cm-mail.stanford.edu/mailman/listinfo/cmdist

Reply via email to