Re:Tail Call Optimization: The Musical
by auggierose on Sunday January 08, 2023 @07:03AM
(#34298387)
What is special about tail call optimisation is that it actually changes the semantics of your program: You now get a guarantee that certain recursive functions do not exhaust the stack space, but behave like a loop. There should really be a language level feature such that you can be sure your functions are not fully recursive, but tail-recursive.
[ Parent
| on HN ]
Re:Tail Call Optimization: The Musical
by consilient on Sunday January 08, 2023 @08:10AM
(#34298817)
You can do this with recursion schemes:
Haskell: https://hackage.haskell.org/package/recursion-schemes
Re:Tail Call Optimization: The Musical
by auggierose on Sunday January 08, 2023 @09:04AM
(#34299166)
Yes, algebraising your control flow to become independent of implementation details like that is a possibility. Of course, you need a language that makes that a) easy, b) performant.
Which recursion scheme guarantees tail-recursion?
Re:Tail Call Optimization: The Musical
by consilient on Monday January 09, 2023 @08:16AM
(#34309958)
`cata` with a cps'd argument