3 ms·
Anyone else dislike the use of 'recur' to indicate iteration?
by tzs 17y ago
Anyone else dislike the use of 'recur' to indicate iteration?
- jrockway 17y agoAnyone else dislike the color #ff0f93 more than #ff0e95?
- tzs 17y agoHow 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?
- lmkg 17y agoThe '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.
- apgwoz 17y agorecursion is the same as iteration in a tail-call optimized environment. Granted, the JVM isn't tail-call optimized, but whatever.
- baddox 17y agoThat seems like common usage. It's used prominently in either SICP or The Little Schemer (I think the latter).
- pivo 17y agoIt 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.