3 ms·
> Basically the output is the unrolled version of the recursion, which cuts down on function invocation (comparatively expensive in dynamic languages). You're
by magicalist 10y ago
> Basically the output is the unrolled version of the recursion, which cuts down on function invocation (comparatively expensive in dynamic languages).
You're right about why it's included, but this is a bug, not a feature. If this is a hot function it'll be optimized. The recursive call is a known, non-dynamic invocation so the function location will be inlined leaving just the fairly low function call overhead itself. There's a reason nobody does arbitrary-length loop unrolls.
I would definitely bet that this is a bug to be fixed :) Right now you can see this if you call fib(20) in that example...the compiler times out while trying to unroll that far. Clearly that behavior won't stick around.