Module: Stupidedi::TailCall

Overview

This performs tail call optimization on methods declared by the programmer
to be in tail call form. It can't actually verify if they are, so be sure
to write tests for your methods.

Because the optimizations are done in pure Ruby, the benefits are somewhat
limited -- the stack doesn't grow but it only begins to outperform the
unoptimized code only when the stack reaches a depth of about 5000 frames.
Before that threshold, it actually performs significantly worse -- about 70%
slower at 50 stack frames, and nearly 100% slower at 10 stack frames.

It seems like this tradeoff makes sense only for methods we know are going to
consistently generate thousands of stack frames. We're probably better off
using Ruby YARV (1.9) in all cases though, since it performs faster in general
and it supposedly implements tail call optimization in the interpreter.