in reply to Re: c-style for loop versus list for loop, and bigint
in thread c-style for loop versus list for loop, and bigint

Because the range operator (integer iterator) is not affected by bigint

Is that intentional?

  • Comment on Re^2: c-style for loop versus list for loop, and bigint

Replies are listed 'Best First'.
Re^3: c-style for loop versus list for loop, and bigint
by BrowserUk (Patriarch) on May 19, 2011 at 20:52 UTC
    Is that intentional?

    Yes. The range operator is intended to be efficient for the majority of every day use cases.

    As you've already discovered, if you need to iterate infinite precision integers, you can easily use the c-style alternative.


    Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
    "Science is about questioning the status quo. Questioning authority".
    In the absence of evidence, opinion is indistinguishable from prejudice.
      > The range operator is intended to be efficient for the majority of every day use cases.

      oh please come on!

      Don't you think use bigint may indicate a non everyday use case?

      Neither bigint nor Math::BigInt mention this problem or even the range operator.

      And maybe it's even possible to fix by overloading ".." in UNIVERSAL.¹

      Cheers Rolf

      UPDATE:

      1) seems like overloading the range operator was never intended: Overloadable Operations

        Neither bigint nor Math::BigInt mention [] the range operator.

        Which to my way of thinking means that this isn't a problem.

        But you'll doubtless have your own meandering & multiply updated opinion.


        Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
        "Science is about questioning the status quo. Questioning authority".
        In the absence of evidence, opinion is indistinguishable from prejudice.
Re^3: c-style for loop versus list for loop, and bigint
by LanX (Saint) on May 19, 2011 at 20:50 UTC
    >Is that intentional?

    let's say it's historical. :)

    I suppose the range iterator is just older than bigint.

    I wouldn't be surprised if bigint is just just a hack to overload scalars with objects and the effect of iterating over a range was forgotten.

    Cheers Rolf

      Actually, I'm fairly certain that the conversion of the range operator from a list generator to an iterator happened long after bigint was available.


      Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
      "Science is about questioning the status quo. Questioning authority".
      In the absence of evidence, opinion is indistinguishable from prejudice.
        hmm could be, I was thinking of the operator not of the iterator, but when using reverse one should get a list like before and it doesn't help either:

        use bigint; my $answer = 1; print ref $answer; # prints "Math::BigInt" for my $i (1..1) { print ref $i; # prints nothing } for my $i (reverse 1..2) { print ref $i; # prints nothing }

        Lets be honest, these kind of problems are one of the reasons why Python is more popular for scientific calculations.

        Cheers Rolf