in reply to (P6) Why the tilde makes sense

5 ~ 09          # >>> "59"

I'm curious, is perl6 also dropping octal numbers? Because the equivalent example in perl5 would complain "Illegal octal digit '9'".

Replies are listed 'Best First'.
Re^2: (P6) Why the tilde makes sense
by TimToady (Parson) on Sep 09, 2005 at 16:50 UTC
    Since octals are less important than they used to be in PDP-11 days, Perl 6 is changing octals to be consistent with hex notation: you have to say 0o777 instead of 0777. (Or use the general radix form, 8:777.)
      The thing about it is that the rest of computerdom interprets 0777 as an octal number. I'm not saying that what's happening here is bad, but I don't understand the drive break convention.

      thor

      Feel the white light, the light within
      Be your own disciple, fan the sparks of will
      For all of us waiting, your kingdom will come

        There is no drive to break convention. There is only the drive to Do It Right this time, which incidentally breaks convention where convention is suboptimal. But all other things being equal, we'll still pick the conventional solution, or something close to it. Often, however, there are several conflicting conventions to pick from.

        In this case, leading zero meaning octal is originally only a Unix convention, not a computerdom convention, and it's a bad convention because the Real World uses leading zeroes on decimal numbers all the time. Why just this morning my daughter was pissed off at a Web form that required her to specify the month as 09 rather than 9. Stupid, but that's the way the Real World thinks...

        But in all of mathdom, 0777 = 777. I can see reasons to break convention. The consistency is nice; everything without a prefix is decimal. Easy to avoid hard-to-spot errors.

        I deal with decimal data on a daily basis that has leading zeroes (input from non-Perl sources). I have more use for fixed-width columns of decimal numbers padded with zeroes so things line up (for example) than for octal numbers.

Re^2: (P6) Why the tilde makes sense
by kelan (Deacon) on Sep 09, 2005 at 18:09 UTC

    Quoting from S02:

    Initial 0 no longer indicates octal numbers. You must use an explicit radix marker for that. Pre-defined radix prefixes include:
        0b          base 2, digits 0..1
        0o          base 8, digits 0..7
        0d          base 10, digits 0..9
        0x          base 16, digits 0..9,a..f (case insensitive)