Skip Menu |
 

This queue is for tickets about the Scalar-List-Utils CPAN distribution.

Report information
The Basics
Id: 47504
Status: resolved
Priority: 0/
Queue: Scalar-List-Utils

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

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)



Subject: sum, overload and bigint
Date: Thu, 2 Jul 2009 12:30:54 +0300
To: bug-Scalar-List-Utils [...] rt.cpan.org
From: zgrim <zzgrim [...] gmail.com>
Download (untitled) / with headers
text/plain 1.2k
Sorry if this has been reported/addressed before, i don't find traces of it. In short, sum() (both XS and PP) ignores possible (lexical) overloadings, which causes problems under, for example, the bigint pragma. IMHO, this should be addressed by either issuing a warning in the documentation, for people not to have the wrong expectations, or by following the overlo(?:a|r)ds. ( checking $^H ? ) Example: ----- #! /usr/bin/perl use warnings 'FATAL' => 'all'; use strict; use 5.010; use List::Util (); my @x = qw( 12345678101234567810123456781012345678101234567832 18765432101876543210187654321018765432101876543226 14321678105432167810543216781054321678105432167874 ); { use bigint; my $sum = sub { my $s = 0; $s += $_ for @_; $s }; say q{(bigint ON) sum @x = }, $sum->( @x ); say q{(bigint ON) List::Util::sum @x = }, List::Util::sum( @x ); } { no bigint; my $sum = sub { my $s = 0; $s += $_ for @_; $s }; say q{(bigint OFF) sum @x = }, $sum->( @x ); say q{(bigint OFF) List::Util::sum @x = }, List::Util::sum( @x ); } __END__ (bigint ON) sum @x = 45432788308543278830854327883085432788308543278932 (bigint ON) List::Util::sum @x = 4.54327883085433e+49 (bigint OFF) sum @x = 4.54327883085433e+49 (bigint OFF) List::Util::sum @x = 4.54327883085433e+49 -----
Download (untitled) / with headers
text/plain 189b
I disagree that there is a general expectation that all subroutines in perl honor lexical pragmas from their caller. I would say it is the opposite in that it is the exception that they do


This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

Please report any issues with rt.cpan.org to rt-cpan-admin@bestpractical.com.