http://arclanguage.org/item?id=9939
My definition of on seems to eval the list only once anyway, but now I'm feeling paranoid about where else I've missed this and taken a performance hit.
You can if you want. It works.
arc> (let a '(prn 5) (once-only (a) `(+ ,a 1))) (with (gs2595 (prn 5)) (+ gs2595 1))
arc> (let a '(prn 5) (once-only a `(+ ,a 1))) Error: "Can't take car of a"
(mac once-only (names . body) (withs (names (check names alist (list names)) gensyms (map1 [uniq] names)) `(w/uniq ,gensyms `(with ,(list ,@(mappend list gensyms names)) ,(with ,(mappend list names gensyms) ,@body))))) arc> (let a '(prn 5) (once-only a `(+ ,a 1))) (with (gs1724 (prn 5)) (+ gs1724 1))
Yeah, your definition's fine because each already handles the multiple-eval situation.
Side note:
(zap [+ 1 _] index)
(zap + index 1)
(++ index)
-----
Thanks for the (zap + index 1) trick.