Skip Menu |
 

This queue is for tickets about the Math-BigInt CPAN distribution.

Report information
The Basics
Id: 110942
Status: resolved
Priority: 0/
Queue: Math-BigInt

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

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



MIME-Version: 1.0
X-Spam-Status: No, score=-4.001 tagged_above=-99.9 required=10 tests=[AWL=-1.303, BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, FREEMAIL_FROM=0.001, HTML_MESSAGE=0.001, RCVD_IN_DNSWL_LOW=-0.7] autolearn=ham
X-Spam-Flag: NO
Content-Type: multipart/alternative; boundary="001a1134f920bd030e05289e9d90"
Message-ID: <CADGpoaOPwP_wqvNAzvpUWkXtbDoMcrgLavDXnM1RrDz=MZXkjA [...] mail.gmail.com>
X-Received: by 10.202.201.77 with SMTP id z74mr66087594oif.24.1452036599896; Tue, 05 Jan 2016 15:29:59 -0800 (PST)
X-Virus-Scanned: Debian amavisd-new at bestpractical.com
X-Spam-Score: -4.001
Received: from localhost (localhost [127.0.0.1]) by hipster.bestpractical.com (Postfix) with ESMTP id 84ED7240343 for <cpan-bug+Math-BigInt [...] hipster.bestpractical.com>; Tue, 5 Jan 2016 18:30:08 -0500 (EST)
Received: from hipster.bestpractical.com ([127.0.0.1]) by localhost (hipster.bestpractical.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id Odn1vq+Wg25a for <cpan-bug+Math-BigInt [...] hipster.bestpractical.com>; Tue, 5 Jan 2016 18:30:07 -0500 (EST)
Received: from la.mx.develooper.com (x1.develooper.com [207.171.7.70]) by hipster.bestpractical.com (Postfix) with SMTP id 06EEC24007B for <bug-Math-BigInt [...] rt.cpan.org>; Tue, 5 Jan 2016 18:30:06 -0500 (EST)
Received: (qmail 12404 invoked by alias); 5 Jan 2016 23:30:06 -0000
Received: from mail-oi0-f54.google.com (HELO mail-oi0-f54.google.com) (209.85.218.54) by la.mx.develooper.com (qpsmtpd/0.28) with ESMTP; Tue, 05 Jan 2016 15:30:03 -0800
Received: by mail-oi0-f54.google.com with SMTP id o124so283824718oia.1 for <bug-Math-BigInt [...] rt.cpan.org>; Tue, 05 Jan 2016 15:30:03 -0800 (PST)
Authentication-Results: hipster.bestpractical.com (amavisd-new); dkim=pass header.i= [...] gmail.com
Delivered-To: cpan-bug+Math-BigInt [...] hipster.bestpractical.com
Subject: Math::BigInt->new() now gives warnings
Return-Path: <miyagawa [...] gmail.com>
X-RT-Mail-Extension: math-bigint
X-Original-To: cpan-bug+Math-BigInt [...] hipster.bestpractical.com
X-Spam-Check-BY: la.mx.develooper.com
Dkim-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:from:date:message-id:subject:to:content-type; bh=H5BS8Mqvx4LCC/Qa4RNTIasxQkSlkCef2M2FIOfzS4w=; b=NQLG8w6jK9XkbRVxYfKyqmfEIlJPxQOm8gAh4fiRfEzWIXWaPdLJvmE0CYbL/rKG0G RDpELjpMqBg5kBBRyupELZn8hlVYjgng6cjpD+KOuk54IVdVibSMi5NtU5Ijg+pMTi8s fxxfbkdCUgdrz9oyQzQgWCccBFnlheMn/4mY5LKsvZQwtUv+tV+gaKzq5atsT2SYgQn8 mdqc8F4LoqLZA0KcMyI+AhZcrSXYVNrjZ13Abnth6LTp+r7MB04RbmMk7cq1zFZHYjyx l7bMPtpw6wPuRDVl/DpJo/a7wz2ISwpFS2d6wisKeybQsJu6nuMxn9U6HRwSiwh03ji1 5Y8Q==
Date: Tue, 05 Jan 2016 23:29:49 +0000
X-Spam-Level:
To: bug-Math-BigInt [...] rt.cpan.org
From: Tatsuhiko Miyagawa <miyagawa [...] gmail.com>
X-RT-Interface: Email
Content-Length: 0
content-type: text/plain; charset="utf-8"
X-RT-Original-Encoding: utf-8
Content-Length: 476
Download (untitled) / with headers
text/plain 476b
Since 1.999712, Math::BigInt->new() gives warnings when it's given undef values or no arguments at all. Show quoted text
> perl -MMath::BigInt -e 'warn Math::BigInt->VERSION; Math::BigInt->new()'
1.999710 at -e line 1. Show quoted text
> cpanm Math::BigInt@1.999712 -n
Successfully installed Math-BigInt-1.999712 (upgraded from 1.999710) 1 distribution installed Show quoted text
> perl -MMath::BigInt -e 'warn Math::BigInt->VERSION; Math::BigInt->new()'
1.999712 at -e line 1. Use of uninitialized value in new at -e line 1
content-type: text/html; charset="utf-8"
Content-Transfer-Encoding: quoted-printable
X-RT-Original-Encoding: utf-8
Content-Length: 743
MIME-Version: 1.0
In-Reply-To: <CADGpoaOPwP_wqvNAzvpUWkXtbDoMcrgLavDXnM1RrDz=MZXkjA [...] mail.gmail.com>
X-Mailer: MIME-tools 5.504 (Entity 5.504)
Content-Disposition: inline
X-RT-Interface: Web
References: <CADGpoaOPwP_wqvNAzvpUWkXtbDoMcrgLavDXnM1RrDz=MZXkjA [...] mail.gmail.com>
Content-Type: text/plain; charset="utf-8"
Message-ID: <rt-4.0.18-19551-1452066376-1675.110942-0-0 [...] rt.cpan.org>
Content-Transfer-Encoding: binary
X-RT-Original-Encoding: utf-8
X-RT-Encrypt: 0
X-RT-Sign: 0
Content-Length: 795
Download (untitled) / with headers
text/plain 795b
On Tue Jan 05 18:30:09 2016, miyagawa@gmail.com wrote: Show quoted text
> > Since 1.999712, Math::BigInt->new() gives warnings when it's > given undef values or no arguments at all.
The warning was introduced on purpose, since you can't have a Math::BigInt object with no value. A Math::BigInt object must be initialized to something, and the warning tells you that you have not specified this "something". The new object will be initialized to zero, though, as before: $ perl -MMath::BigInt -wle 'print "x = ", Math::BigInt -> new()' Use of uninitialized value in new at -e line 1 x = 0 but if you want a zero, the right way to do it is with bzero() or new(0). I can't see why this warning is a problem, but if you can explain to me when or why this warning might be a problem, I will consider removing it.
MIME-Version: 1.0
X-Spam-Status: No, score=-5.945 tagged_above=-99.9 required=10 tests=[AWL=0.753, BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, FREEMAIL_FROM=0.001, FROM_OUR_RT=-4, HTML_MESSAGE=0.001, RCVD_IN_DNSWL_LOW=-0.7] autolearn=ham
In-Reply-To: <rt-4.0.18-19551-1452066376-1971.110942-6-0 [...] rt.cpan.org>
X-Spam-Flag: NO
X-RT-Interface: API
References: <RT-Ticket-110942 [...] rt.cpan.org> <CADGpoaOPwP_wqvNAzvpUWkXtbDoMcrgLavDXnM1RrDz=MZXkjA [...] mail.gmail.com> <rt-4.0.18-19551-1452066376-1971.110942-6-0 [...] rt.cpan.org>
X-Virus-Scanned: Debian amavisd-new at bestpractical.com
X-Received: by 10.182.241.3 with SMTP id we3mr68698917obc.82.1452096355360; Wed, 06 Jan 2016 08:05:55 -0800 (PST)
Message-ID: <CADGpoaOJbrJWkwALzWpa3CFWOH46B+xZFmveDMKz8sdPOFc0QQ [...] mail.gmail.com>
Content-Type: multipart/alternative; boundary="001a11c3608c70e8740528ac87fd"
X-Spam-Score: -5.945
Authentication-Results: hipster.bestpractical.com (amavisd-new); dkim=pass header.i= [...] gmail.com
Received: from localhost (localhost [127.0.0.1]) by hipster.bestpractical.com (Postfix) with ESMTP id 720C824020A for <cpan-bug+Math-BigInt [...] hipster.bestpractical.com>; Wed, 6 Jan 2016 11:06:05 -0500 (EST)
Received: from hipster.bestpractical.com ([127.0.0.1]) by localhost (hipster.bestpractical.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id FkuqAmCMtVeX for <cpan-bug+Math-BigInt [...] hipster.bestpractical.com>; Wed, 6 Jan 2016 11:06:03 -0500 (EST)
Received: from la.mx.develooper.com (x1.develooper.com [207.171.7.70]) by hipster.bestpractical.com (Postfix) with SMTP id 7F5A72400B7 for <bug-Math-BigInt [...] rt.cpan.org>; Wed, 6 Jan 2016 11:06:03 -0500 (EST)
Received: (qmail 22210 invoked by alias); 6 Jan 2016 16:06:02 -0000
Received: from mail-ob0-f170.google.com (HELO mail-ob0-f170.google.com) (209.85.214.170) by la.mx.develooper.com (qpsmtpd/0.28) with ESMTP; Wed, 06 Jan 2016 08:05:59 -0800
Received: by mail-ob0-f170.google.com with SMTP id xn1so29041971obc.2 for <bug-Math-BigInt [...] rt.cpan.org>; Wed, 06 Jan 2016 08:05:59 -0800 (PST)
Delivered-To: cpan-bug+Math-BigInt [...] hipster.bestpractical.com
Subject: Re: [rt.cpan.org #110942] Math::BigInt->new() now gives warnings
Return-Path: <miyagawa [...] gmail.com>
Dkim-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :content-type; bh=zZJZ9gX9CdmRfs5fnhVzuaLNDCdVUphRc5p5fhYrIwA=; b=HB2foejpw6938zKHADTYfK0XcMqTPJGTAmEDt4iqmH5qB4SVLVwbAqH+c8RcJRFy4W OAFupY7px/KWbr1iLkxTvrkow5MLj2usSA6OnbwERBmGQvT9/so/9KOPvEYfHJ3EJMBj BL80kTUW4pKAPW3lJNeWclJztpSonGbg+xbFqO7DTVUndkTFOcgTjPdsqA/E6LH3DCrc 6zUoEvqvS4NYu5qJKW5TNdeZemufQig2XKauYeAmERghfNsS0lvcilxQWzTUwfnJBKGK vBG3x1lsZs+PALbaDIoTiNEUT6mMzk2YdW8eZZLMO3InLjX0v1G/IKsKxMRSuY9UXXOM YHOw==
X-Spam-Check-BY: la.mx.develooper.com
X-Original-To: cpan-bug+Math-BigInt [...] hipster.bestpractical.com
X-RT-Mail-Extension: math-bigint
Date: Wed, 06 Jan 2016 16:05:46 +0000
X-Spam-Level:
To: bug-Math-BigInt [...] rt.cpan.org
From: Tatsuhiko Miyagawa <miyagawa [...] gmail.com>
RT-Message-ID: <rt-4.0.18-11940-1452096366-1468.110942-0-0 [...] rt.cpan.org>
Content-Length: 0
content-type: text/plain; charset="utf-8"
X-RT-Original-Encoding: utf-8
Content-Length: 1269
Download (untitled) / with headers
text/plain 1.2k
OK, understood, except that the code was called in some other perl module, Math::BaseConvert and as a user I cannot stop the warnings. It means that we should just patch the module though. https://metacpan.org/source/CHROMATIC/Math-BaseConvert-1.7/lib/Math/BaseConvert.pm#L48 On Tue, Jan 5, 2016 at 11:46 PM Peter John Acklam via RT < bug-Math-BigInt@rt.cpan.org> wrote: Show quoted text
> <URL: https://rt.cpan.org/Ticket/Display.html?id=110942 > > > On Tue Jan 05 18:30:09 2016, miyagawa@gmail.com wrote:
> > > > Since 1.999712, Math::BigInt->new() gives warnings when it's > > given undef values or no arguments at all.
> > The warning was introduced on purpose, since you can't have a Math::BigInt > object with no value. A Math::BigInt object must be initialized to > something, and the warning tells you that you have not specified this > "something". > > The new object will be initialized to zero, though, as before: > > $ perl -MMath::BigInt -wle 'print "x = ", Math::BigInt -> new()' > Use of uninitialized value in new at -e line 1 > x = 0 > > but if you want a zero, the right way to do it is with bzero() or new(0). > > I can't see why this warning is a problem, but if you can explain to me > when or why this warning might be a problem, I will consider removing it. >
content-type: text/html; charset="utf-8"
Content-Transfer-Encoding: quoted-printable
X-RT-Original-Encoding: utf-8
Content-Length: 1891
MIME-Version: 1.0
In-Reply-To: <rt-4.0.18-19551-1452066376-1675.110942-0-0 [...] rt.cpan.org>
X-Mailer: MIME-tools 5.504 (Entity 5.504)
Content-Disposition: inline
X-RT-Interface: Web
References: <CADGpoaOPwP_wqvNAzvpUWkXtbDoMcrgLavDXnM1RrDz=MZXkjA [...] mail.gmail.com> <rt-4.0.18-19551-1452066376-1675.110942-0-0 [...] rt.cpan.org>
Content-Type: text/plain; charset="utf-8"
Message-ID: <rt-4.0.18-18594-1452293697-1449.110942-0-0 [...] rt.cpan.org>
Content-Transfer-Encoding: binary
X-RT-Original-Encoding: utf-8
X-RT-Encrypt: 0
X-RT-Sign: 0
Content-Length: 919
Download (untitled) / with headers
text/plain 919b
This is related: Old code: $ perl -MMath::BigInt -E 'say Math::BigInt::blcm(); say Math::BigInt::bgcd()' 0 0 New: $ perl -MMath::BigInt -E 'say Math::BigInt::blcm(); say Math::BigInt::bgcd()' Use of uninitialized value in new at -e line 1. 0 Use of uninitialized value in new at -e line 1. 0 I think gcd and lcm with an empty list should work without warning, but I can see an argument otherwise. However this warning is confusing. The code is relying on the old behavior. (1) if the new(undef) warning goes away, this problem goes away. (2) totally untested and unofficial change to the start of the function: my $y = shift || 0; my($x); (3) Add before that line the totally untested and unofficial change: return $class->bzero() unless @_; (4) similar to the above but basically doing the same as the old code did with that: return $class->new(0) unless @_;
MIME-Version: 1.0
In-Reply-To: <rt-4.0.18-11940-1452096366-1468.110942-0-0 [...] rt.cpan.org>
X-Mailer: MIME-tools 5.504 (Entity 5.504)
Content-Disposition: inline
X-RT-Interface: Web
References: <RT-Ticket-110942 [...] rt.cpan.org> <CADGpoaOPwP_wqvNAzvpUWkXtbDoMcrgLavDXnM1RrDz=MZXkjA [...] mail.gmail.com> <rt-4.0.18-19551-1452066376-1971.110942-6-0 [...] rt.cpan.org> <CADGpoaOJbrJWkwALzWpa3CFWOH46B+xZFmveDMKz8sdPOFc0QQ [...] mail.gmail.com> <rt-4.0.18-11940-1452096366-1468.110942-0-0 [...] rt.cpan.org>
Content-Type: text/plain; charset="utf-8"
Message-ID: <rt-4.0.18-5931-1452326550-778.110942-0-0 [...] rt.cpan.org>
Content-Transfer-Encoding: binary
X-RT-Original-Encoding: utf-8
X-RT-Encrypt: 0
X-RT-Sign: 0
Content-Length: 788
Download (untitled) / with headers
text/plain 788b
On Wed Jan 06 11:06:06 2016, miyagawa@gmail.com wrote: Show quoted text
> OK, understood, except that the code was called in some other perl > module, Math::BaseConvert and as a user I cannot stop the warnings.
Hm. That is unfortunate, but on the other hand, that's what might happen when people don't read the documentation. For more than 12(!) years, since Math-BigInt-1.67, released in December 2003, the documentation has stated: Currently, Math::BigInt::new() defaults to 0, while Math::BigInt::new('') results in 'NaN'. This might change in the future, so use always the following explicit forms to get a zero or NaN: $zero = Math::BigInt->bzero(); $nan = Math::BigInt->bnan(); Perhaps I should change the warning to something like Using new() or new("") is deprecated.
MIME-Version: 1.0
In-Reply-To: <rt-4.0.18-18594-1452293697-1449.110942-0-0 [...] rt.cpan.org>
X-Mailer: MIME-tools 5.504 (Entity 5.504)
Content-Disposition: inline
X-RT-Interface: Web
References: <CADGpoaOPwP_wqvNAzvpUWkXtbDoMcrgLavDXnM1RrDz=MZXkjA [...] mail.gmail.com> <rt-4.0.18-19551-1452066376-1675.110942-0-0 [...] rt.cpan.org> <rt-4.0.18-18594-1452293697-1449.110942-0-0 [...] rt.cpan.org>
Content-Type: text/plain; charset="utf-8"
Message-ID: <rt-4.0.18-18473-1452326814-1093.110942-0-0 [...] rt.cpan.org>
Content-Transfer-Encoding: binary
X-RT-Original-Encoding: utf-8
X-RT-Encrypt: 0
X-RT-Sign: 0
Content-Length: 458
Download (untitled) / with headers
text/plain 458b
On Fri Jan 08 17:54:57 2016, DANAJ wrote: Show quoted text
> I think gcd and lcm with an empty list should work without warning, (...)
I agree. At the same time I would like to discourange using blcm() and bgcd() as functions. At the very least, they should be used class methods. I am also annoyed by the fact that they don't modify their object, which is inconsistent with the rest of the interface, but I'm not sure this can be done without causing more harm than good.
MIME-Version: 1.0
In-Reply-To: <rt-4.0.18-18594-1452293697-1449.110942-0-0 [...] rt.cpan.org>
X-Mailer: MIME-tools 5.504 (Entity 5.504)
Content-Disposition: inline
X-RT-Interface: Web
References: <CADGpoaOPwP_wqvNAzvpUWkXtbDoMcrgLavDXnM1RrDz=MZXkjA [...] mail.gmail.com> <rt-4.0.18-19551-1452066376-1675.110942-0-0 [...] rt.cpan.org> <rt-4.0.18-18594-1452293697-1449.110942-0-0 [...] rt.cpan.org>
Content-Type: text/plain; charset="utf-8"
Message-ID: <rt-4.0.18-734-1459794213-57.110942-0-0 [...] rt.cpan.org>
Content-Transfer-Encoding: binary
X-RT-Original-Encoding: utf-8
X-RT-Encrypt: 0
X-RT-Sign: 0
Content-Length: 882
Download (untitled) / with headers
text/plain 882b
On Fri Jan 08 17:54:57 2016, DANAJ wrote: Show quoted text
> This is related: > > Old code: > > $ perl -MMath::BigInt -E 'say Math::BigInt::blcm(); say > Math::BigInt::bgcd()' > 0 > 0 > > New: > > $ perl -MMath::BigInt -E 'say Math::BigInt::blcm(); say > Math::BigInt::bgcd()' > Use of uninitialized value in new at -e line 1. > 0 > Use of uninitialized value in new at -e line 1. > 0 > > I think gcd and lcm with an empty list should work without warning.
I have looked further into this. I am not sure what bgcd() and blcm() with no argument should return. Currently they return zero, but to me that seems like an arbitrary choice. I checked with Octave and Wolfram Alpha. The former requires at least two input arguments. The latter requires at least one. Does it make sense at all that bgcd() and blcm() return zero? Could you, or someone else, show me a case where this result is useful?
MIME-Version: 1.0
In-Reply-To: <CADGpoaOPwP_wqvNAzvpUWkXtbDoMcrgLavDXnM1RrDz=MZXkjA [...] mail.gmail.com>
X-Mailer: MIME-tools 5.504 (Entity 5.504)
Content-Disposition: inline
X-RT-Interface: Web
References: <CADGpoaOPwP_wqvNAzvpUWkXtbDoMcrgLavDXnM1RrDz=MZXkjA [...] mail.gmail.com>
Content-Type: text/plain; charset="utf-8"
Message-ID: <rt-4.0.18-2506-1461325643-1453.110942-0-0 [...] rt.cpan.org>
Content-Transfer-Encoding: binary
X-RT-Original-Encoding: utf-8
X-RT-Encrypt: 0
X-RT-Sign: 0
Content-Length: 18
Fixed in v1.999717


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.