Slide 84
Slide 84 text
option = {
tailcall_optimization: true,
trace_instruction: false,
}
iseq = RubyVM::InstructionSequence.new(<<-EOF,
"fact.rb", '/', nil, option).eval
class Tailcall
def fact(n, r=1)
if n < 2
r
else
fact(n-1, n*r)
end
end
end
EOF
Tailcall.new.fact(30_000)
Tuesday, October 9, 12