<div dir="ltr">oh wow, ok I will chew on that. In the meantime, I got it working as this, but feedback for style (or bugs I can't see) would be lovely. <div><br></div><div>;building on the example from Bill:<br>(define s4m-expr-inputs (vector '() 11 22 33)) <br><br>(define (string->sexp text)<br> "convert a string of an sexp to an sexp"<br> (read (open-input-string text)))<br><br>; recursive iterator for processing an sexp for %X args<br>(define (s4m-process-sexp sexp)<br> (map<br> (lambda(token)<br> (cond <br> ((and (symbol? token) (eq? ((symbol->string token) 0) #\%))<br> `(s4m-expr-inputs ,(string->number (substring (symbol->string token) 1))))<br> ((list? token)<br> (s4m-process-sexp token))<br> (else token)))<br> sexp))<br><br>(define-macro (s4m-run-sexp-macro sexp)<br> `(eval (s4m-process-sexp ,sexp)))<br><br>(define (s4m-run-expr sexp-str)<br> (let ((input-sexp (string->sexp sexp-str)))<br> (s4m-run-sexp-macro input-sexp)))<br></div><div><br></div><div>I also noticed I could thus dispense with the oneline macro all together now by doing:</div><div><br></div><div>(define (s4m-run-expr sexp-str)<br> (let ((input-sexp (string->sexp sexp-str)))<br> (eval '(eval (s4m-process-sexp input-sexp)))))<br></div><div><br></div><div>Feedback on which is considered better style welcome!</div><div>iain</div><div><br></div><div><br></div><div><br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Wed, Sep 8, 2021 at 11:03 AM <<a href="mailto:bil@ccrma.stanford.edu">bil@ccrma.stanford.edu</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">This isn't helpful, in fact it's ugly, but I can't<br>
resist mentioning:<br>
<br>
(set! *#readers*<br>
(cons (cons #\% (lambda (str)<br>
(list 's4m-expr-inputs<br>
(string->number (substring str 1)))))<br>
*#readers*))<br>
<br>
> (+ #%1 (+ #%2 #%3))<br>
<br>
which returns 66 after expanding at read time to:<br>
<br>
(+ (s4m-expr-inputs 1) (+ (s4m-expr-inputs 2) (s4m-expr-inputs 3)))<br>
<br>
</blockquote></div>