Skip to content
Will Coleda edited this page Nov 11, 2022 · 1 revision

Tail Call Optimization

Rakudo does not currently have implicit TCO.

Adding a mechanism for explicit tail calling would be fine, but this needs runtime support, and is potentially more complex due to Routines having non-inlined blocks. Because of this, there might be many VM-level stack frames that need to be removed.

But tail call optimization is very tricky because features like CALLER and dynamic variables are impacted; the late-bound nature of those mean they can be used at quite a distance

So if rakudo gets tailcalls, they'll need to be explicit, and someone needs to do the implementation work.