Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:105452 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 44815 invoked from network); 26 Apr 2019 08:14:33 -0000 Received: from unknown (HELO mail-ua1-f68.google.com) (209.85.222.68) by pb1.pair.com with SMTP; 26 Apr 2019 08:14:33 -0000 Received: by mail-ua1-f68.google.com with SMTP id k32so787444uae.3 for ; Thu, 25 Apr 2019 22:15:37 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:reply-to :from:date:message-id:subject:to; bh=Ds4qwFf45Xh+xb+oxOR9e4wo82S1WJp/GKWN+0gi908=; b=k1Asp7PVgR9OLrZyDEO0MDQvLYBEbqnLAzg37+ULOtQGeBOsl2zzOaJFsxjoUdhC3i fsJ5Ela50YeXQkRplZRsAQqypWucFumk23UA6pYgCynzmpPW0t/u0B19DKz6XwNUBCgF ExwC/CsHHG3gBaqCjMZGa2VKWA50ErPW3FkU/ClrXpwUIQKPcXIXvsAymkqe2O5+fGWe B6c8nXgthfR2CeLC9+6Fes+eJi1CdbabJ3Tesf9IXYJvHIo6unUr/rf0LwuJ7bA77K2a B6QgdeU7hDtaEOP/qJh6cHkX87avBaKf7qCyEh9iKzWHnwhjslaYZpybNdwF035b+gXJ KVLg== X-Gm-Message-State: APjAAAXqjic3CtSByoAxf5kdzEKsK0L6Qtl+DWOD6qP3c6hugvO/M+cg GfBak3NYvtUNTaR0fnTtF1d7+St/O5iTYMJgLcixY1PZ X-Google-Smtp-Source: APXvYqxbDlBrN0DnA9+NnSkhveDSKWpIj8PRcwNlpqiqWbhC3w1i8T9uh7ooGNR84k3hRMFWZ4TrvDRpqNVhkeAvGFU= X-Received: by 2002:a9f:350f:: with SMTP id o15mr918637uao.143.1556255736262; Thu, 25 Apr 2019 22:15:36 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: Reply-To: bishop@php.net Date: Fri, 26 Apr 2019 01:15:10 -0400 Message-ID: To: PHP internals Content-Type: multipart/alternative; boundary="00000000000056f8480587680658" Subject: Re: [PHP-DEV] Revive Number Format Separator RFC From: bishop@php.net (Bishop Bettini) --00000000000056f8480587680658 Content-Type: text/plain; charset="UTF-8" On Thu, Apr 25, 2019 at 9:28 PM Bishop Bettini wrote: > On Thu, Apr 25, 2019 at 6:07 PM Theodore Brown > 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 --00000000000056f8480587680658--