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

> The first observation is that you can't do it at compile time. I've seen at least one blog entry that used a bytecode hack to replace a CALL opcode immediately before a RETURN opcode with a jump to the top of the function body. This may be a nice demo, but unfortunately Python's compiler cannot reliably determine whether any particular call is actually reference the current function, even if it appears to have the same name.

Tail call elimination should handle mutual recursion too, so this is completely unnecessary to check, and any CALL in tail position should become a tail call. Ironically I found this post from https://news.ycombinator.com/item?id=40504141 which is all about using mutual recursion to encode automata.



Consider applying for YC's Winter 2027 batch! Applications are open till November 2.

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

Search: