4 ms·
I noticed a few languages removing support for octal and binary literals. I wonder why. I find them useful and the parser overhead seems minimal to keep them ar
by jjnoakes 7y ago
I noticed a few languages removing support for octal and binary literals. I wonder why. I find them useful and the parser overhead seems minimal to keep them around.
- wtetzner 7y agoYeah, it never made sense to me not to include those, given how simple it is.
- marquis-chacha 7y agoThe typical octal literal syntax I've seen uses a 0 prefix. This gives rise to quite a few gotchas, as most people think of leading 0's as being non-value-changing. Maybe 0o12345670?
- wtetzner 7y agoYeah, I agree that it's not a good syntax. I do think 0o is a good prefix though.
- ergothus 7y agoGenerally developers tend to either (1) misunderstand them when they encounter them in the wild or (2) accidentally invoke them. (I believe multiple languages have had issues with '04' being treated as an octal, which works fine and doesn't trigger developer notice until they encounter '09' in the wild). Whether these are VALID concerns I won't take a stance on - just saying these are the reasons I've seen cited.
- wtetzner 7y agoWhy not use 0x,0b, and 0o for hex, binary, and octal literals? I never liked the fact that a number starting with 0 was treated as octal.
- steinuil 7y agoOCaml does just that; it might have been the first language to have 0b and 0o prefixes for binary and octal literals. https://discuss.ocaml.org/t/the-origin-of-the-0b-01-notation/3180 https://discuss.ocaml.org/t/the-origin-of-the-0b-01-notation...
- natefaubion 7y agoWe found no usages of it in the wild. If there is real-world need for them, we'll consider adding them back.
- scrollaway 7y agoFWIW I use binary literals a bunch in python, either when working with binary file formats or with bitfields.
- natefaubion 7y agoYes, I'm not saying there aren't usages for them in general, but PureScript currently occupies a niche that doesn't get down to the level of binary file formats. This change is more about "only supporting what we need to right now", rather than "we don't like binary literals". As noted elsewhere, it's not difficult to add support for them when we need to.