On Thu, Sep 10, 2015 at 12:54 PM, Anders Fugmann wrote: > Another possibility would be to only perform TCO on recursive functions. Disabling the optimizations works in some cases, but it considerably alters the characteristics of the executed program. Programs that wouldn't reach the stack limit suddenly does, and programs that would run fast are now considerably slower. In a controlled test situation it may be worthwhile to turn off optimizations of this kind, but I've always had the feeling that this is something you have to accept for the real world deployments when requesting what a program is doing. As long as you know what is happening, reconstructing the code flow path usually isn't that hard. And OCaml isn't the only language in which this is a problem. It hits Standard ML, Erlang, and Haskell too, the latter having its own additional irregularities due to lazy evaluation. And inlining optimizations have hit me when using DTrace on C code because the optimizer decided to inline functions aggressively, which in turn removes those as targets for function boundary tracing. -- J.