On Thu, Apr 25, 2019 at 9:28 PM Bishop Bettini <bis...@php.net> wrote:
> On Thu, Apr 25, 2019 at 6:07 PM Theodore Brown <theodor...@outlook.com> > wrote: > >> Is there any chance the Number Format Separator RFC [1] could be revived >> for PHP 7.4? I looked at the discussion from a few years ago and it's not >> clear why many people originally voted against it. >> >> JavaScript and Python have both gotten this feature recently and it's >> something I really miss in PHP when declaring/reading large numbers. >> >> Maybe it would help to simplify how the restrictions are described in the >> RFC. As I understand it, the only restriction is that each underscore in a >> numeric literal must be between two digits. Perhaps the way the RFC >> described this syntax made it seem more complex than it is. >> >> Best regards, >> >> Theodore Brown >> >> [1]: https://wiki.php.net/rfc/number_format_separator > > > Subsequent conversation occurred on the voting thread [1], which wasn't > included by reference in the RFP itself. > > The only dissent I saw in that thread came from Pascal Martin, speaking > for AFUP, who wrote [2]: > > it would be harder to search in code, as there would be more than > > one way to write a number. Basically, it would break grep/find. > > Splitting numbers so they are more readable is kind of a presentation > > matter and, as such, could be done by an editor/IDE when displaying > > code, without having to modify the code by hand > > Related: the RFC author Tom Punt also detailed the implementation, but > didn't incorporate that by reference into the RFC [3]. Worth the read. > > With Tom's blessing, I'd support re-visiting this feature. It's useful, > IMO. > > [1]: https://marc.info/?l=php-internals&m=145271098232484&w=2 > [2]: https://marc.info/?l=php-internals&m=145320709922246&w=2 > [3]: https://phpinternals.net/articles/implementing_a_digit_separator > Using a variant of Nikita's top packages visitor [1], the top 250 packages contain about 3 million integer literals. Of those, about 800k have 5 or more digits, while only about 3k have 10 or more digits. Nine digits is unusually common, because of its use in giggsey/libphonenumber-for-php for United States phone numbers. Applying some rough heuristics to file names, 89% of those literals appear in a data file, 8% in code, and 3% in tests. A cursory scan of current usage suggests that number format separator might be used in scenarios such as: Phone numbers 919_555_1234 49_89_636_48018 Date time values 2018_04_26 20180426_183242 Range end points (using any locale's grouping strategy) 2_147_483_647 1_67_77_215 Nibble groups 0b0011_1111_0100_1110 For those first few, Kotlin has similar examples [2], but Javascript discourages use of number separator in "number-ish" values (eg phone numbers) [3]. https://gist.github.com/bishopb/157d403dc1c190957a558c93e120a07d [1]: https://gist.github.com/nikic/a2bfa3e2f604f66115c3e4b8963a6c72 [2]: https://kotlinlang.org/docs/reference/basic-types.html#underscores-in-numeric-literals-since-11 [3]: http://2ality.com/2018/02/numeric-separators.html