Skip to content

Instantly share code, notes, and snippets.

@jsl
Created January 15, 2014 19:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jsl/8442724 to your computer and use it in GitHub Desktop.
Save jsl/8442724 to your computer and use it in GitHub Desktop.
Testing Ruby's tail-call optimization
def test_stack_size(call_count = 0)
puts "Current call count: #{call_count}"
test_stack_size(call_count + 1)
end
RubyVM::InstructionSequence.compile_option = {
:tailcall_optimization => true,
:trace_instruction => false
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment