A simpler buggy version:
====================
sub g($x, $y){
  say "$x $y";
  h($y, $x);
}

sub h($x, $y){
  say "$x $y";
}

g(10, 15);
=====================
This prints:
10 15
15 15


--abhijit

Abhijit Mahabal wrote:
the file examples/hanoi.p6 should work correctly, but does not. Something is going wrong in the recursion.

=========================
[EMAIL PROTECTED] trunk]$ ./pugs examples/hanoi.p6
ndisks = 3
AS
AS
SS
AB
SS
SB
SB
=========================

A modified version that also prints out what arguments the function saw spews this out:

=========================
[EMAIL PROTECTED] trunk]$ ./pugs ../../b2.p6 3
ndisks = 3
Called for 3 discs with A B S
Called for 2 discs with A S S
Called for 1 discs with A S S
Called for 0 discs with A S S
Disk 1 from A to S
Called for 0 discs with S S S
......
=========================

So something is wrong somewhere. Could it be that the function is treating its variables not as "my" but something else? That is my guess, but that something else is not the perl5 "local" or the perl5 "our" because they would not produce this particular error.

I plan to explore this more later today.

--abhijit

Reply via email to