develooper Front page | perl.perl5.porters | Postings from August 2001

RE: [PATCH List::Util] fix stack/scoping problems

Thread Previous
From:
Wilson, Doug
Date:
August 21, 2001 15:59
Subject:
RE: [PATCH List::Util] fix stack/scoping problems
Message ID:
35A280DF784CD411A06B0008C7B130ADB5510E@sdex04.sd.intuit.com

> From: Robin Houston [mailto:robin@kitsite.com]

> The patch below is an attempt to fix the problem reported by 
> Doug Wilson.
> It seems to work, but I'd appreciate it if someone (Graham?) 
> could make
> sure I haven't done anything too hideous.

Getting close :) but the following still fails no matter where
I put the PUSH & POP BLOCK. If I uncomment everything below, all the
values echoed by warn() appear to be correct, but the value that
finally makes it to '$sum' is null. However, if I put a
'svREFCNT_inc(ST(0));'
right before the POPBLOCK (with the POPBLOCK after the loop),
then it works ok. Someone let me know if this is the right thing to do...


sub add {
    #warn "0:$_[0] 1:$_[1]";
    $_[0] + $_[1];
}

my @list = ([3,0],[2,0],[1,0]);
my $sum = reduce {
                   #warn "a1: $$a[0] b1: $$b[0]";
                   #my $tmp =
                   [ 0+add($$a[0], $$b[0]), 0 ];
                   #warn "a2: $$a[0] b2: $$b[0] tmp: $$tmp[0]";
                   #$tmp;
                 } @list;

warn "sum: $$sum[0]";
print "not " unless $$sum[0] == 6;
print "ok 6\n";

Thread Previous


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About