-----BEGIN PGP SIGNED MESSAGE-----

Moin,

On 11-Mar-02 Hugo van der Sanden tried to scribble about:
> Tels <[EMAIL PROTECTED]> wrote:
>:The first is a tad difficult with bignum right now. Yes,
>:
>:        perl -Mbignum=p,0 -le 'print 9/4'
>:        2
>:
>:but this is a lot slower than just doing it in BigInt-space
> 
> 'If you want ints you know where to find them.'
> 
>:but still, how about:
>:
>:        perl -Mbignum=i -le 'print 9/4'
>:
>:or how about:
>:
>:        perl -Mbigint -le 'print 9/4'
>:
>:as a handy shortcut to:
>:
>:        perl -MMath::BigInt=:constant -le 'print 9/4'
>:
>:? Does anybody have an idea why I might not add this? And which form
>:do you prefer? ;)
> 
> Does it need a shortcut? How many people so often write bigint one-liners

Me ;)

> that need integer division _and_ are speed-sensitive that they need
> a shorthand for it?

One-liners are not the only usage. While I often use them to demonstrate
things, the idea is more that you can say:

        use bignum;

or

        use bigint;

at the top of your script and have it to work "automagically" in
bigint/bigint+bigfloat/bigrat space without worrying about all the details.

While it seems stupid to do so as a replacement for use Math::BigInt
':constant', it isn't, actually. Namely, use bigint would do fare
more in the background. I am not talking about use bignum; - that this is
superior to the large preamble you need when you want to get BigFloat and
BigInt to work together for transparent support should be obvious ;)

What I am talking about is that bigint (or bignum=i, whatever people prefer)
also would trick to get things like to work:

        perl -MMath::BigInt=:constant -le 'print 1e10->bmul(2)'
        Can't call method "bmul" without a package or object reference at
        -e line 1.

This does not work, since '1e10' is considered a float by Perl, so Bigint's
:constant doesn't pick it up, so the bmul() won't work.

        use bigint;

would make this to work, without the need to for you:

* to modify BigInt to pick up float constants (Yes, a subclass could take
  care of that, but then you can also have use bignum ;)
* or load BigFloat just to have it to downgrade 1e13 to BigInt

I agree about the speed increase beeing not important for onliners
(although the saving for not having to load BigFloat could make a
difference). But use bigint; would also load Lite when possible, and also
probably (that occured just to me) use "lib => 'GMP,Pari'" as default.

> In my own case, I use bigints from time to time, but hardly ever in
> one-liners, and certainly not often enough that I'd ever remember
> a shortcut. I'm happy enough with C<use Math::BigInt qw/ constant />.

Fine for you ;) But it has it's limitations, and that is were -Mbigint
would come into play ;)

The idea is that "use bigfoo;" is just a short way to get all these details
right. If you want to do it manually, it starts to get tedious:

        use Math::BigInt::Lite;
        use Math::BigInt lib => 'GMP,Pari', ':constant';

and that would even fail if Lite is not there, and doesn't even take into
account constants like 12.5E1 ;)

> In any case if you have a bigmath shell, you'd probably tend to use that
> rather than a direct invocation of perl:
> 
> % bmsh -ie '9/4'
> 2
> %
> 
> .. which is a far more effective shortcut. :)

Where can I get that shell? 

Cheers,

Tels

- -- 
 perl -MDev::Bollocks -e'print Dev::Bollocks->rand(),"\n"'
 collaboratively industrialize front-end networks

 http://bloodgate.com/perl       My current Perl projects
 PGP key available on http://bloodgate.com/tels.asc or via email

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.6 (GNU/Linux)

iQEVAwUBPI0sTXcLPEOTuEwVAQFSwQf9F3sJdRX3MPRaAGxKlRKACA5YZvhSgy6H
W31R/AFrmwL5eIQJ1f8JBcOYgAs11Z1hgsRxWN4oLi+PMaTG7m6b/O+pAZbN9QTd
G6kEG+1dyMf63RUgaOnRAoND/9BXPNUpt0hYIh5TbydjtUg/PoPS7AlbT9AIAAgU
CcrzLXqa3zNPLGmcf5vh6jShQ0fbnEzOdOmprAIpYspSaJmCfZXbXw3baQOR2HYG
g5HvWHF9+xTMR6lpco343DqYm+OCJbnHKKqlQkDnMxRLUggDMGVcR/C1JK6H3HNq
Op4su9xwehJI2DA7CIpAQkDfAcFf7MWf6axtQvbzly3hvaLDEgQmTw==
=jjI6
-----END PGP SIGNATURE-----

Reply via email to