36 points · by fogus · 16y ago · 17 comments
The code clears the stack slot for the count method argument. If the object referenced by the argument is not referenced elsewhere, then the object is eligible for gc during the execution of the count method. In the case where the argument is a lazy sequence, this changes the memory requirement from the entire realized sequence to a single item in the sequence.
This trick is employed everywhere in the Clojure implementation where a lazy sequence might be retained. It's not specific to the count function.
... then it means you're completely disconnected from reality?
Edit: Can a down-modder make a convincing argument that a performance benchmark using Fibonacci is even useless, rather than worse than useless by being an appealing lure toward optimizing the wrong things?
Something useful that uses recursion, perhaps. A DFS comes to mind, or countless other common real-world algorithms.
When do you ever care about recursion performance in the context of a function that does nothing but one addition? You might as well compare languages on how well a billion iterations of an empty loop performs.
Your objection is like looking at a floating-point benchmark and thinking, "No real program just crunches doubles. It should include networking code and exception handling."