3 ms·
I wouldn't have use a macro... A normal function would have done pretty much the same job...
by siscia 12y ago
I wouldn't have use a macro...
A normal function would have done pretty much the same job...
- wtbob 12y agoThe advantage of a macro is that one doesn't have to wrap one's own code in a closure. It's cleaner to write `(try-n-times (let ((foo (bar 1))) (baz foo 2)) 3)` than `(try-n-times (lambda () (let ((foo (bar 1))) (baz foo 2))) 3)`. Also: man, writing Lisp without paren-matching bites.
- GregBuchholz 12y ago...but then you've just pushed the lambda somewhere else: (map (lambda (x) (try-3 x)) collection-of-try-threeables) ...that's why a lightweight anonymous function notation is useful (Clojure's #() reader macro, etc.).
- wtbob 12y agoUmmm, `(map (lambda (x) (try-3 x)) …` could just be written as `(map #'try-3 …)`
- JamesSwift 12y agoThe core logic was defined as a function. The shorthand 'try3' was macro which calls through to that function.