6 ms·
If you write ruby and want TCO put this at the top of your .rb file: RubyVM::InstructionSequence.compile_option = { :tailcall_optimization => true,
by yror10 12y ago
If you write ruby and want TCO put this at the top of your .rb file:
RubyVM::InstructionSequence.compile_option = {
:tailcall_optimization => true,
:trace_instruction => false
}
- damncabbage 12y agoAnd also apply this patch, if you're using MRI (the C implementation, and the most common Ruby runtime): https://gist.github.com/plexus/11201946 https://gist.github.com/plexus/11201946
- eknkc 12y agoWhy is it optional? What is the benefit of having it disabled by default if there is a decent implementation?
- Tuna-Fish 12y agoA lot of people prefer having complete, explicit stacks for debugger use over having tail calls.
- hajile 12y agoloops don't leave a stack trace either...
- anonova 12y agoThey disabled it for error reporting/debugging reasons. Because you don't need to create a new stack frame, you eliminate that information in the backtrace.
- steveklabnik 12y agoI've seen at least one paper that shows a way to fix this... hm.