in reply to Re: Pragma clash across modules: bignum and Math::BigFloat
in thread Pragma clash across modules: bignum and Math::BigFloat

> bignum is meddling with the globals $Math::BigFloat::downgrade and $Math::BigInt::upgrade.

I haven't checked in detail yet (the code is a bit obscure) but this sounds reasonable.

But I disagree when you say

> There's really no way for bignum to do the right thing. It would have to muck around with those globals every time the flow of control entered or left its lexical scope. And the automatic upgrade feature was just a bad idea from the start. Solution: Don't use bignum, I'm afraid.

Athanasius point was not why bignum fails but why the use of pragma bignum is effecting a completely other package, since pragmas are guaranteed to be limited to a scope.

It's rather a limitation of BigFloat and BigInt to use global variable which keep their state even if the scope is left.

perlpragma shows a clear mechanism to limit effects to the scope using a pragma with the help of the hinthash %H .

Since "bignum is just a thin wrapper around various modules of the Math::BigInt family" those modules should be modified in a way to check a delegated hinthash when called from a pragma. (N.B. they share the same authors)

Hence a bug, in my humble opinion.

Anyway using globals for such profound effects is never a good idea.

Cheers Rolf
(addicted to the Perl Programming Language and ☆☆☆☆ :)
Je suis Charlie!

update

according to perlglossary#P

I'm not sure if bignum qualifies as a pragma, because of it's rather runtime effects.

  • Comment on Re^2: Pragma clash across modules: bignum and Math::BigFloat (hinthash)
  • Download Code

Replies are listed 'Best First'.
Re^3: Pragma clash across modules: bignum and Math::BigFloat (hinthash)
by Anonymous Monk on Dec 07, 2016 at 22:36 UTC
    Pragmas are named in all lowercase.
    But not everything that is named in all lowercase is a pragma. Take use lib, for instance. Not a pragma; it globally changes @INC. bignum tried to be a pragma, but gave up halfway.
      The definition is indeed fuzzy.

      But in the case of lib I'd opt for pragma because it's a compile time effect and the globality is intended.

      > bignum tried to be a pragma, but gave up halfway.

      I agree.

      For instance a Tie::Scalar on $upgrade and $downgrade to a routine checking the hinthash could do without even changing BigFloat and family.

      Cheers Rolf
      (addicted to the Perl Programming Language and ☆☆☆☆ :)
      Je suis Charlie!

        The problem is that bignum is arcane and weird. Your solution is to make it more arcane and weird. IMO the right solution is to make it less arcane and weird: just have it convert all numbers to BigFloats. All this upgrading and downgrading between BigInts and BigFloats is a silly waste of time.