Hi,
TCO (Tail-Call Optimization) shouldn’t (and cannot) be disabled as a whole, due to how central recursive functions are. That’s OK.
However in some cases TCO leads to ellipses in the stacktraces that make debugging way harder than it should be (e.g. the frame “jumps” from an entry point in one’s code to the failing code deep in a given library, knowing that in-between dozens of calls made from one’s code to that library may have led to such an error). Good luck to easily find which.
I do not think that there are compile flags to disable TCO on a per-module/function basis, but apparently wrapping one’s potentially-guilty code in a try/catch clause as a whole (at least extending to the function return; just for the sake of debugging) is sufficient to disable TCO for that function, and to add back in the stacktrace the offending code, so that we at last obtain a relevant line number in that function to scrutinize. It seems to me a neat (temporary) trick.
But maybe there are simpler/cleaner/less invasive ways to do the same?
Thanks in advance for any hint,
Olivier.