Is there any way to tell if a function in F# is tail-recursive?
I've tried to explain it, but some people seem to struggle and ask if there's a way to confirm what they've done is tail recursive. Is there anything easy you can do (other than trying to make it overflow the stack) to confirm tail responsiveness (or not) (preferably in the IDE)?
(I tried Reflector, but it just crashes on me when I open F# projects!)
From here (with several examples in the article):
How can I verify that tail calls are being used?
The easiest way is to ensure that tail calls are being used is to understand and apply the rules from the previous section. While the F# compiler itself doesn’t currently provide any way to verify that tail calls have been used at a particular call site, you can be sure by looking at the compiled version of the code using the MSIL Dissasembler (ildasm.exe). We’ll see several examples below.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With