Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:83150 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 30637 invoked from network); 19 Feb 2015 07:21:53 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 19 Feb 2015 07:21:53 -0000 Authentication-Results: pb1.pair.com header.from=vchkpw@developersdesk.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=vchkpw@developersdesk.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain developersdesk.com designates 204.228.229.4 as permitted sender) X-PHP-List-Original-Sender: vchkpw@developersdesk.com X-Host-Fingerprint: 204.228.229.4 lessa.developersdesk.com Received: from [204.228.229.4] ([204.228.229.4:55316] helo=mail.developersdesk.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id C1/21-22021-01F85E45 for ; Thu, 19 Feb 2015 02:21:53 -0500 Received: (qmail 32416 invoked by uid 89); 19 Feb 2015 07:21:50 -0000 Received: from unknown (HELO ?192.168.0.151?) (vchkpw@developersdesk.com@96.19.163.170) by 0 with ESMTPA; 19 Feb 2015 07:21:50 -0000 Message-ID: <54E58F06.1040707@developersdesk.com> Date: Thu, 19 Feb 2015 00:21:42 -0700 User-Agent: Mozilla/5.0 (Windows NT 6.1; rv:31.0) Gecko/20100101 Thunderbird/31.4.0 MIME-Version: 1.0 To: internals@lists.php.net References: <54E5456E.4020103@gmx.de> <54E54E1E.1010906@lerdorf.com> In-Reply-To: <54E54E1E.1010906@lerdorf.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Subject: Re: [PHP-DEV] Digit separators for numeric literals From: vchkpw@developersdesk.com (Rick Widmer) On 2/18/2015 7:44 PM, Rasmus Lerdorf wrote: > On 02/18/2015 06:07 PM, Christoph Becker wrote: >> Hi internals! >> >> A while ago a question was asked on the php-general mailing list with >> regard to digit seperators in numeric literals[1]. >> >> IMHO it might be a useful enhancement to allow such digit separators for >> numeric (integer and float) literals in PHP for better readability; >> several other languages already support them (such as Java, Perl, Ruby, >> C#, Eiffel and C++14). >> >> Before attempting to draft a respective RFC, I'd like to get some >> feedback, whether this is generally considered to be useful, which >> character would be preferred (most other languages seem to allow the >> underscore, but an apostroph or maybe some other character might be >> reasonable as well), and which restrictions should be applied (e.g. >> arbitrary use of the separator, group thousands only, etc.) >> >> I'm looking forward to hear your opinion. Thanks in advance. >> >> [1] > > I think it will be difficult to find a separator character that doesn't > make a mess of the grammar. > > my_func(1,999,999) obviously doesn't work > my_func(1'999'999) as per C++14 clashes with our single-quoted strings > my_func(1_999_999) like in ADA might work > > but _999_ would need to work as well and _ is a valid char in a constant > so you can have a constant named _999_. > > - nope > # nope > @ nope > ~ nope > ! nope > % nope > ^ nope > > We went through this for the namespace char, and there simply isn't a > typable single character left to use for something like this. _ is the > closest but it would require some changes and BC breaks which I am not > sure is worth for what appears to me to be a not-so critical feature. > > Now if we went into Unicode territory, we could do it. eg. > > my_func(1 999 999) U+1680 (although it looks too much like a -) > my_func(1 999 999) U+205F (mathematical space) > my_func(1٬999٬999) U+066C (Arabic thousands separator) > my_func(1·999·999) U+00B7 (middle dot) > > The last one looks best to me, but we'd need a team of people working in > shifts to answer the, "How do I type this?" question. > > -Rasmus how about: my_func( '1,000.04' ); //if you want to use separators there. Rick. Who is firmly in the camp that considers type juggling an essential feature of PHP.