Stories
Slash Boxes
Comments
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
 Full
 Abbreviated
 Hidden
More | Login | Reply
Loading... please wait.
  • by karavelov (8706) on 2008.11.26 23:16 (#66021)

    I have not found Moritz's code for the man or boy test. My try with the last revision goes to 9. It reaches max recursion depth for 10. Here it is:

    sub A($k is copy, $x1, $x2, $x3, $x4, $x5) {
    my $B = sub { A(--$k, $B, $x1, $x2, $x3, $x4) };
    $k <= 0 ?? $x4() + $x5() !! $B();
    }
    say A(9, sub{1}, sub{-1}, sub{-1}, sub{1}, sub{0} );

    What is the need for & sigil you mention? I have done by hand some crude tailcall optimization in the generated PIR and it reaches the recursion depth limit on 13... go figure.

    • I have not found Moritz's code for the man or boy test.

      Moritz's test is here: http://svn.pugscode.org/pugs/t/spec/integration/man-or-boy.t [pugscode.org]

    • You don't have to use the & sigil, but if you do (e.g. sub foo (&x) { ... }) then you can call the sub just as x() within the sub foo.

      It's not surprising that implementing the tailcall optimization helped. I suspect we need to be a tad careful when choosing to emit such things in the compiler, since it may screw up the CALLER pseudo-package...not thought too much about the full implications of this for optimization yet though and it may or may not turn out to matter...