I would like to see a .tail IL .tail , but simple recursive functions using tail calls that I wrote are apparently optimized for loops. I actually have a hunch about this, since I'm not quite sure what the loop in Reflector looks like. I definitely don't see any .tail codes. I have a "Generate tail calls" checked in my project properties. I also tried both Debug and Release builds in Reflector.
The code I use is F # Programming by Chris Smith , p. 190:
let factorial x = // Keep track of both x and an accumulator value (acc) let rec tailRecursiveFactorial x acc = if x <= 1 then acc else tailRecursiveFactorial (x - 1) (acc * x) tailRecursiveFactorial x 1
Can someone suggest some simple F # code that will actually generate .tail ?
kld2010
source share