Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Don’t we have debug symbols or something like it to be able to translate the optimised version into the thing you saw in code? If you need to dive into the assembly you are in for a hell of a ride anyway due to all kinds of optimisations happening.


And tail recursive functions encode their state in the args and the body. There isn't any information in the stack anyway, by definition.

If one does need to debug mutually tail recursive functions, step through them, this isn't a problem. The point is that they don't consume stack space. If you do want a stack of invocations, then don't write tail recursive code?

This style of argumentation that the GP showed should have a name.

BTW my original comment is at -1, hate but only in the tail position.


> There isn't any information in the stack anyway, by definition.

This is untrue. There are 3 possibilities:

  1. Constant stack space (perhaps zero) across calls with caller-cleanup
  2. Callee-cleanup
  3. Caller-cleanup where an argument indicates how much stack space to clean/where to set the stack pointer


If you what you say is true, it still doesn't survive N+1 invocations, we are talking about 1,2,3 vs infinity.

My statement still stands, there is _next to no_ information in the call stack of TCO enabled functions. Which is by design.




Consider applying for YC's Winter 2026 batch! Applications are open till Nov 10

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: