Re:Slashdot Book Reviews: Programming Clojure
by tzs on Monday May 17, 2010 @05:41PM
(#1355666)
Anyone else dislike the use of 'recur' to indicate iteration?
[ Parent
| on HN ]
It bothered me at first but after not too much time began to feel pretty reasonable. I have a few issues with the language but they're really just trivial ones. Clojure has become my favorite language, so I can't complain too much.
That seems like common usage. It's used prominently in either SICP or The Little Schemer (I think the latter).
Re:Slashdot Book Reviews: Programming Clojure
by jrockway on Monday May 17, 2010 @06:54PM
(#1355853)
Anyone else dislike the color #ff0f93 more than #ff0e95?
How is that comparable? The word 'recur' suggests recursion, so using it to mean you do NOT want recursion seems to be kind of odd. Does it make sense to you?
The 'recur' operator was meant as a replacement for the lack of tail-recursive optimization in the JVM, and is often seen as a recursion operator, not an iteration operator, especially by people coming from a functional background. People from an imperative background seem to understand it as a type of limited GOTO, with only a single place it can go to; people from a functional background see it as similar to calling the function you're in by name, but mentioning the recursion explicitly for compiler optimizations.
Recur seems to be maligned by people on both sides of the recursion/iteration divide. I rather like it, in no small part because I think the divide is silly. Iteration is the same as recursion, both semantically (especially if you have tail-call optimization) and syntactically (especially if you can have multiple loop variables). Recur blurs the distinction. If you think the distinction is important, it's confounding; if you think the distinction is silly, it's unifying.