http://qs321.pair.com?node_id=1173169


in reply to Re^15: why are hex values not numbers? (octal)
in thread why are hex values not numbers?

Um... If you are going to give a reason, I already ceded octal earlier in this discussion, for compatibility reasons. I limited my suggestion to constants beginning with "0x".

As for 0xabcdef being a color code, that confusion already exists now, since color codes are, often, not in quotes. So the problem of "confusion" already exists.

So I already excluded octal and someone came up with color codes in hex, which are already oft unquoted, so no increase in confusion w/that example.

So back to the simple case of showing problems where allowing an auto-convert of 0x12 to 18, in a numeric context (where today, it would generate an error).

Part of the problem in finding an example where it would be a problem is you'd have to present buggy code as the example. Code that only runs with a warning and generates '0' as a binary value when used in a numeric context. That's why detractors can't find an example: it would be an example of non-working code.

Now does anyone get the point? The only way someone can accidently use "0x123456" as a binary value today...um...is they can't! They get a warning and the constant "0x123457" evaluates as binary zero. There can be no confusion in current code, because trying to decode a hex constant in a string returns a zero.

As for future code. Maybe allowing hex constants anywhere decimal constants are, as in almost any other language, won't be so confusing to "just perl programmers", since programmers in other languages don't get so easily confused -- why would anyone protest that perl programmers would?

Replies are listed 'Best First'.
Re^17: why are hex (not octal) values not numbers?
by Anonymous Monk on Oct 03, 2016 at 18:31 UTC
    I already ceded octal: So, now it's only hex-like strings you want to make a special case of. The ideas wearing a bit thin isn't. someone came up with color codes in hex, which are already oft unquoted,: It doesn't have to be quotes -- its in a string. It's only you wants to be able to treat that ambiguous string as a number.

    You're like a dog with a bone tied to its tail, chasing around in circles refusing to let go! Fatuous.

    A reply falls below the community's threshold of quality. You may see it by logging in.