Subject: | Global variables aren't thread safe |
The following variables should be migrated to the OO interface:
$round_mode
$accuracy
$precision
$upgrade
$downgrade
Or rather, the OO interface should keep local copies of these variables.
As it stands right now, changes via $obj->option($val) will change the
global variables directly. That breaks thread safety and the overall
expectations of an OO interface.
It should work like this:
* A call to new, copy, or any of the number creation methods should also
create a local copy of the global variables in the blessed object, if
$self doesn't already exist.
* A call to one of the methods above or 'config' should:
if (exists $self->{var}) { return|set $self->{var}; }
elsif (blessed $self) { create a local copy then return|set; }
else { return|set $global; }
* All internal calls that use these variables should use $self->option
and never the globals directly.
This will ensure that calls to '$obj->option' or '$obj->config' use the
local variables, and calls to 'Math::BigInt->option' or
'Math::BigInt->config' directly change the global options.