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

> So, my questions are:

> 1. Is this a bug?

Yes! ³

> 2. How can a pragma declared in one namespace affect the behaviour of code in a different (and supposedly separate) namespace?

See PerlPragma - such in Perl implemented "module" pragma are normally supposed to set and check the hinthash to restrict actions to the calling scope.

This is only done for bignum itself

But the globals set in Math::BigFloat don't adapt to this.

And no bignum is not setting them back. ²

> 3. Is there a workaround that will allow me to keep the current implementations of my two solutions and run them together in the same test script?

What is a workaround what is a patch?

Please try to prove that unsetting $upgrade and $downgrade solves it. *

If yes, you could patch the importer of the effected modules to reset those flags or even better replace them with getters checking the hinthash.

Tie::Scalar could be an option for this.

In any case please file a bug report!!!

A core pragma sabotaging other namespaces is a very worrying thing.

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

updates

footnotes

*) like indicated by AnoMonk here

²) not fixing delegated global flags (import options) in its own unimport

sub unimport { $^H{bignum} = undef; # no longer in + effect overload::remove_constant('binary', '', 'float', '', 'integer'); }

³) because experiencing an unpredictable distant effect from a remote sub-module in the dependency chain is not OK. Especially when caused by a CORE pragma