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

Re: Views on changing Math-BigInt OO design

Thread Previous | Thread Next
From:
Peter John Acklam
Date:
October 7, 2015 13:42
Subject:
Re: Views on changing Math-BigInt OO design
Message ID:
CAEvoY41cokDgxU0p-UFNJYCq==J=n+W+FS3QZv8jjbH7PA45TA@mail.gmail.com
(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)'
  8

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)'
  +8E+0

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?

Peter

2015-07-29 4:05 GMT+02:00 John Peacock <john.peacock@havurah-software.org>:

> 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


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