Skip Menu |

This queue is for tickets about the Sub-Curried CPAN distribution.

Report information
The Basics
Id: 44074
Status: resolved
Priority: 0/
Queue: Sub-Curried

People
Owner: Nobody in particular
Requestors: metaperl [...] gmail.com
Cc:
AdminCc:

Bug Information
Severity: Important
Broken in: 0.06
Fixed in: 0.09



Subject: function thinks it was called with more arguments than it was
The cycle.pl example in the distro <http://cpansearch.perl.org/src/OSFAMERON/Sub-Curried-0.06/examples/cycle.pl> does not work. I broke down the steps and the problem is that the curried version of scanl has some delusions about the number of args it is called with: use strict; use warnings; use Sub::Curried; curry take ($count, $it) { return map { $it->() } 1..$count; } curry cycle (@list) { my @curr = @list; return sub { @curr = @list unless @curr; return shift @curr; }; } curry scanl ($fn, $start, $it) { my $curr = $start; return sub { my $ret = $curr; $curr = $fn->($curr, $it->()); return $ret; }; } curry times ($x,$y) { $x * $y } my $iterator = cycle( [2.5, 2, 2] ) ; my $scanl_curried = scanl(times); # scanl called with 4 args, expected 3 at scanl2.pl line 30 my $r = $scanl_curried->(10, $iterator); warn $iterator, $scanl_curried, $r;
I *think* the problem is that something changed somewhere (I think in D::D) that stopped curry subs from being defined at compile time. This meant among other things that the definition of the builtin perl function 'times' no longer got overridden by the curried version. If you rename the function 'mult' then it should run as expected - I've uploaded 0.07 which has an examples/cycle.pl that works for me... please let me know if that fixes it. (I still need to declare the functions first though... I may need to use Devel::BeginLift... on TODO for next iteration)
On Mon Apr 27 07:17:13 2009, OSFAMERON wrote: Show quoted text
> I *think* the problem is that something changed somewhere (I think in > D::D) that stopped curry subs from being defined at compile time. This > meant among other things that the definition of the builtin perl > function 'times' no longer got overridden by the curried version. > > If you rename the function 'mult' then it should run as expected - I've > uploaded 0.07 which has an examples/cycle.pl that works for me... please > let me know if that fixes it. > > (I still need to declare the functions first though... I may need to use > Devel::BeginLift... on TODO for next iteration)
From 0.09 Devel::BeginLift fixes this issue - and 0.10 works on 5.8.8 too. Closing.