Hi Leo,
sorry for the delayed answer. I was looking to something smart to say over this topic, but nothing came :) Indeed, I don't have tested yet patterns like expression template to make any pertinent remark there.
> you should probably also set `TAILCALLS` to -1
Thx for pointing this out.
>This also means that unconditionally inlining recursive functions can send the compiler into an infinite loop.
For C++ (the only interpreter I know a little), this is left under the user responsibility. When such infinite loop occurs, then the user payback its freedom spending a lot of time to blindly understand why its interpreter rose an exception. I don't know whether it is a good idea or not.
> This is conceptually simpler, but would bloat the syntax tree and mostly (?) not help much.
See remark above.
In a first phase, having inlined version of fn:fold-left (maybe naming it as hof:fold-left would be safer ?) should be enough, and safer, since you should know in advance the call depth. Shall (INLINE = ?) control the depth call ?
I did not have a look to the code yet, but I was wondering how can you detect recursive calls ? The self recursive case seems easy to detect, but if I glue two functions together, it seems trickier.
Cheers
Jean-Marc