develooper Front page | perl.perl5.porters | Postings from October 2015

Re: Views on changing Math-BigInt OO design

Thread Previous | Thread Next
Peter John Acklam
October 7, 2015 13:42
Re: Views on changing Math-BigInt OO design
Message ID:
(Pardon me if it is considered bad form to bring up an old discussion,
but I would like to keep this discussion in one place.)

I realized that converting Math::BigInt into a subclass will make it
impossible to use the following non-OO syntax, which is still supported:

  $ perl -MMath::BigInt -wle 'print Math::BigInt::badd(3, 5)'

Even my soon 20 year old version of The Camel Book does not mention this
syntax, so I doubt it is much used anymore, but there could stille be
some old code that will break if this syntax no longer works.

Way back one could also use

  $ perl -MMath::BigFloat -wle 'print Math::BigFloat::fadd(3, 5)'

but this non-OO syntax was no longer possible when Tels' re-written
version of the Math-BigInt distribution was merged into core Perl with
the commit 58cde26e9566cfa700a6d18945c4428f22c6be85 from Jun 16 2001.

In essence, if I go on with my idea, Math::BigInt::badd(3, 5) will have
to be written as Math::BigInt -> badd(3, 5). Is that such a big problem
that I should leave the code as it is?


2015-07-29 4:05 GMT+02:00 John Peacock <>:

> On 07/28/2015 09:28 AM, Peter John Acklam wrote:
>> Abigail, thanks for pointing out the implicit loading. I hadn't though
>> of that, although hopefully I would have discovered it while testing.
>> Here is my current idea
>> - introduce Math::BigNum
>> - let Math::Big(Int|Float|Rat) each be a subclass of Math::BigNum
>> - for backwards compatibility, let Math::BigFloat load Math::BigInt, and
>> let Math::BigRat load Math::BigFloat
> Have you audited CPAN to see what modules are already subclassing M::BF,
> like my own Math::Currency?  I would be interested in getting a pre-release
> package, which may finally induce me to fix the locale tests that have been
> failing for a very long time.
> John

Thread Previous | Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About