Re:A Practical Optional Type System for Clojure
by jimbokun on Thursday October 25, 2012 @12:17PM
(#4698156)
Your three line version is pretty much equivalent to this part of the Clojure version:
The rest of it appears to be performance optimizations, that probably make sense for a key function in the core library likely to be commonly invoked.
[ Parent
| on HN ]
Re:A Practical Optional Type System for Clojure
by dschiptsov on Thursday October 25, 2012 @12:32PM
(#4698217)
There are some subtle differences, which makes the whole sense.
Classic version has a self-evident clarity and familiar shape of a recursive function, which utilizes TCO.
Perfection is achieved when there is nothing more to cut off, not when there is nothing more to pile up.)
Re:A Practical Optional Type System for Clojure
by spacemanaki on Thursday October 25, 2012 @03:13PM
(#4699024)
Is the classic one actually going to be able to leverage tail-call elimination? Obviously it could be refactored to make a tail-recursive call, but correct me if I'm wrong, it wouldn't be automatic.
After refactoring it, the tail-recursive version would be a bit harder to read than the naive implementation. In a sense the Clojure code is in the same boat, it's just that the optimizations are more complicated, because it's not working with singly linked lists in the "address register" and "decrement register".