-----BEGIN PGP SIGNED MESSAGE-----
Moin all,
Dan wrote a lot sensible things about Transparent BigInt/BigFloat support.
I am all for it. ;-P
Reasons:
It's the Perl way. (Int => Float already works that way)
Speed (For small numbers, use fast INT, for larger uses BigInt; currently
you must use BigInt everywhere if you numbers _might_ overflow, resulting
in very slow code for 1+2=3)
It solves a lot of problems with overload, :constant etc.
It's also shorter code - Math::BigInt->new(+2) is a lot to type ;)
But there are some points I like to make nonetheless:
There are currently a lot of BigInt modules, but most (if not all) of them
are slow, incorrect, or incompatible/unusable. This lead me to rewrite
BigInt/BigFloat etc (shameless plug: http://bloodgate.com/perl - v1.21 soon
on CPAN). There is also a lot of talk going on on how to drag Bit::Vector
into it, etc.
However, all the accumulated wisdom should not be scrapped and the
wheel reinvented just for Perl 6. I do not know how feasible it is to
"plug-in" the current BigInt support into the core, but I think the exact
working ways/representation of such a big number should be left up to the
implementation. This would allow, for a quick working example, the existing
modules to be "plugged-in" and later on to be replaced with faster, native
code. Maybe Bit::Vector with a wrapper, or some other library. (since Perl
is in C, I do not know how usefull it is to have a native type coded in
Perl - but heh, it could work ;)
Even the now pure-Perl bigint implementation is faster than the
original, and combined with the transparent support it would be of good
speed for Perl (not perfect, I know, but then look at how it is today -
broken ;o) until we find a replacement.
Also, there are good bignum c libraries (gmp) already, someone (not me,
mind you, I am terrible at math and licences ;) should be look into the to
see wether they could be used.
And then, if we have BigFloat, we need a way to specify rounding and
precision. Otherwise 1/3 eats up all memory or provides limits ;o)
I think I like:
use precision 40; # round to 40 digits after dot
use rounding 'towards_zero';
And for Int-like behaviour:
use rounding 'truncate'; # etc
use precision 0;
Oh, what should "use integer" do?
So, if transparent support is done, then Math::BigInt, Math::BigFloat
should be empty hulls and anything using them (Math::String f.i) must be
adjusted accordingly. I will do this, of course ;)
Otherwise, I am looking forward to Perl 6. Yes, I am getting exciting ;o)
Please keep me informed of any progress/changes.
Best regards,
and thanx for all your work,
Tels
PS: I did not follow all the suggestions, so please bear with me if I
missed something.
- --
perl -MMath::String -e 'print \
print Math::String->from_number("+215960156869840440586892398248"),"\n"'
http://bloodgate.com/thief/ Thief - The Dark Project
http://bloodgate.com/perl My current Perl projects
http://freedomforlinks.de Fight for your right to link.
PGP key available on http://bloodgate.com/tels.asc or via email
-----BEGIN PGP SIGNATURE-----
Version: 2.6.3i
Charset: latin1
iQEVAwUBOsNrP3cLPEOTuEwVAQGDTgf+KtsRPMKzpXhy5gcKRTsRDHvnRnRJbvsG
wG8Ulesz88ZXd+1SgOqryJC0pyZv4enW0xBHVBLpDk8wiEfIUBvkKkN8DHHB9ZB5
WNMm+I60ayvZtrl0TQVS6PFwYi+Eo2N9juRwJN7iANgR0tT0/ZTjXJupnieeCZfw
PxSVYaEhk6ENdDdiT0svSRamEyDQwjJFsUttRr4ZO5bLrY7jadLhJIdpsJuXpwWw
b3QT/4dracbtjkWzDjkvXqgnLRCaPH3smD/h6IdYeRzb1W/4rids37ljs8OFweyP
qPJ2xUiSo+uNWPfPXC9RQFSs2LnFGgPvbpYITZKpiBKMdcUiJIu7Ug==
=8hwP
-----END PGP SIGNATURE-----