Repository navigation
Could MIR (eventually) be used to compile a language with tail call elimination? #409
|
From the blog posts, the README and a few other discussions, I understand that MIR currently assumes the C calling convention. Given that tail call elimination (TCE) is not doable with that convention, that seems to suggest that TCE is, at least for now, out of reach for any compiler targeting MIR (at least without trampolining or complicated heuristic code transformations). Although the thing going on with thunks might create opportunities here? I don't understand enough about the inner workings of MIR, or compilers in general for that matter, to draw my own conclusions on that front. Functional programming languages often like to employ tail call elimination as a loop primitive. Are such languages within the scope of MIR, or do you plan to support them in the future? What would be your advice to someone who wants to implement such a language and benefit from the high speed, low latency execution profile that MIR offers? In any case, thank you for this very interesting project! |
Replies: 2 comments 8 replies
|
@vnmakarov and @derekbsnider please allow me to draw your attention to this topic. |
|
@jgonggrijp It is possible. I believe |
I've attached what Claude thinks will be required, which matches broadly what I would expect:
An issue Claude flagged that I hadn't spotted is a restriction on the tail…