News for hackers. Stuff that matters.
Re:Mindset Shifts for Functional Programming by chriswarbo on Wednesday April 05, 2023 @01:27PM (#35457581)
> On paper perhaps, but I have yet to see a compiler that can take any arbitrary recursive subroutine and automatically optimize it into a Tail Call Optimized (that is, transform the recursive parts into goto/jumps similar to a loop) version.

General recursion can be modelled coinductively via the "Delay" or "Partial" type, e.g. https://arxiv.org/abs/cs/0505037

Type-inference can figure out when recursive calls need to be wrapped in `Later`. We can then compile into a single `while` loop to unwrap the layers.

There are no comments on this comment yet.