http://www.perlmonks.org?node_id=1025195


in reply to Re: Incrementing "Infinity" bug (numification, perlnumber, magic increment decrement)
in thread Incrementing "Infinity" bug

It's a bug or at least a design flow.

Creating a constant which returns a numified inf easily fixes this problem

DB<100> use constant inf => inf+0 => 0 DB<101> $a=inf => "inf" DB<102> ++$a => "inf" DB<103> ++$a => "inf"

So why doesn't Perl do this per default?

do we really need to use hacks like 1e9999 to create inf?

Cheers Rolf

( addicted to the Perl Programming Language)

  • Comment on Re^2: Incrementing "Infinity" bug (numification, perlnumber, magic increment decrement)
  • Select or Download Code

Replies are listed 'Best First'.
Re^3: Incrementing "Infinity" bug (numification, perlnumber, magic increment decrement)
by Anonymous Monk on Mar 25, 2013 at 07:17 UTC

    It's a bug or at least a design flow.

    How do you figure? I think it isn't

    So why doesn't Perl do this per default?

    You know why, tradition (backwards compatibility ). "barewords" have always been strings

    Also style, lowercase constants are unbecoming :p

    do we really need to use hacks like 1e9999 to create inf?

    We never needed that, use  0+'inf' or  int '-inf' ...

    But hey, one of the math modules could export ... or even  use feature 'infinity'; could happen though I don't see the benefit, but what do I know

    $ perl -le " for(1..4){ print for \int 'infinity', \int'-infinity' } +" SCALAR(0x99bc74) SCALAR(0x99bc64) SCALAR(0x99bc74) SCALAR(0x99bc64) SCALAR(0x99bc74) SCALAR(0x99bc64) SCALAR(0x99bc74) SCALAR(0x99bc64)

    update: nans, infs, and vomit, How to create nan/inf says bigint/bigrat export inf that stringifies to inf

    Also note Re^3: nans, infs, and vomit (underlying c-runtime and strtod, atof)

      > We never needed that,

      I showed a use case producing short, self-explanatory code with the use of inf.

      > use 0+inf or int '-inf' ...

      sure, why not introducing one more level of cryptic workarounds to justify perl's reputation of a line-noise-language instead of having self explanatory constants?

      > update:

      well ... no comment on the fact of an AnoMonk who can update his nodes ...;-)

      Cheers Rolf

      ( addicted to the Perl Programming Language)

        > We never needed that,
        I showed a use case producing short, self-explanatory code with the use of inf.

        But what has that got to do with the whack/hack 1e9999 ?

        $ perl -le " print for 1 .. 0+'Inf'" Range iterator outside integer range at -e line 1.

        sure, why not introducing one more level of cryptic workarounds to justify perl's reputation of a line-noise-language instead of having self explanatory constants?

        you know, I linked to the docs, the explanation, and the inf constant exporters (bigrat/bigint )

        perl is fundamentally what it is, and it works the way it has for over a decade, if you don't like it, don't use it; calling it line-noise and cryptic at every turn is uninspired and uninteresting

        update:

        well ... no comment on the fact of an AnoMonk who can update his nodes ...;-)

        Boring :/