[% setvar title Unrolling loops and tail recursion %]

This file is part of the Perl 6 Archive

Note: these documents may be out of date. Do not use as reference!

To see what is currently happening visit http://www.perl6.org/


Unrolling loops and tail recursion


  Maintainer: Simon Cozens <simon@brecon.co.uk>
  Date: 25 Sep 2000
  Mailing List: perl6-internals@perl.org
  Number: 302
  Version: 1
  Status: Developing


Implement loop unrolling and tail recursion elimination as optional optimisations.


Tail recursion elimination is something which has been on the todo for a long time, but I think nobody's done it because it's really really hard. I'd suggest

    use optimize 'recursion';

would be a natural syntax, if less turns into optimize.

Unrolling of loops is something that becomes important for compiling to standalone executables; I think

    use optimize 'unroll-loops';

would be the way to signify that. If we have a standalone compiler, I'd suggest the cc-style -f... command-line options.


I have no idea how to implement tail recursion elimination, and I'd dearly love to learn. Unrolling loops with constant indices shouldn't be too hard.


RFC 303: Keep use less, but make it work.