Moin mark,
On Thursday 10 April 2008 23:05:19 Mark Overmeer via RT wrote:
Show quoted text> Queue: Math-BigInt
> Ticket <URL:
http://rt.cpan.org/Ticket/Display.html?id=34822 >
> > Moin Mark,
> Hi Tels,
> > The library that is loaded last, wins. Basically, any line of "use
> > Math::BigInt lib => 'foo';" will try to load "Math::BigInt::foo"
> > and if successfuly, use this library from this point on.
>
> I understand the problems designing the interface, but it gives major
> problems, certainly when there is dynamic loading in play as well.
Well, duh! :)
The library interface was designed to allow changing the library instead
of hardcoding it in - it wasn't thought at that time that there would
be a change of library at run-time, or that this would actually cause
the problems with objects that were constructed between loading of two
different libraries - for the very simple reason that back than nobody
even thought of these scenarios.
(I clearly should have thought things more through, but well, I
didn't :)
Show quoted text> > Note that switching libraries _after_ constructing already
> > Math::BigInt objects is a bad idea, as these objects cannot mix,
> > e.g. if $a was constructed library GMP and $b with Calc, you cannot
> > do "$a + $b" as this will blow up spectaculary :)
>
> You may freeze the library at INIT or CHECK type.
I may? Apart from the fact that I don't know how how to do this, I am
also not sure that changing it now would actually work.
Show quoted text> > For libraries that are used by other programs (e.g. you case) there
> > are a few cases how to solve this:
> > * just do "use Math::BigInt" and let the user decide which library
> > to use underneath. (needs doc and education)
>
> But then the user needs to add "use Math::BigInt", what they do not
> expect. But I can try to describe it in the "performance" chapter
> of the docs.
Yes that is the drawback of this method.
Show quoted text> > * do like Math::String, use "try => GMP" and add a requirement for
> > Math::BigInt v1.88.
>
> The problems people report me are 1.87 in many Linux distributions,
> in combination with the problems with dual-lived modules...
This is squarely my fault because I didn't release v1.88 of Math::BigInt
about half a year ago.2007-01-27 v1.78 Tels
* implement "try" and "only" as replacements for "lib"
However, the "try" and "only" keywords were added in v1.78 of
Math::BigInt, which is a bit older:
2007-01-27 v1.78 Tels
* implement "try" and "only" as replacements for "lib"
But I guess with the slow-moving target of distributions, that this is
in still quite a lot of distributions.
As far as "try" and "only" are concerned, they were added that late
because well, nobody really had the problem (except me), and I simple
couldn't/didn't think of this before.
The interface was made up as I got along, which clearly shows.
Show quoted text> > Hope that clears this up, I think it might be described somewhere
> > in the documentation, but it is surely buried.
> > Sorry that this is so complicated.
>
> That's life ;-)
If I can improve the doc or code, tell me how and I see if I can include
these things into v1.89. Probably won't help you,but maybe the next
guy :)
best wishes,
Tels
PS: Using "GMP" over "Calc" is not a simple black-and-white issue,
because for small numbers GMP is actually slower than Calc. So the
decision on wether to use GMP or Calc or whatever should really be left
to the application that loades the modules. Yes, that makes it more
complicated for the app while this detail should be hidden, but this
cannot be easily changed (unless someone invents a way to speed up the
GMP library for very small numbers - which is unlikely :)
--
Signed on Thu Apr 10 23:15:08 2008 with key 0x93B84C15.
View my photo gallery:
http://bloodgate.com/photos
PGP key on
http://bloodgate.com/tels.asc or per email.
"We're looking at a future where only the very largest companies will
be able to implement software, and it will technically be illegal for
other people to do so."
-- Bruce Perens, 2004-01-23