Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:105797 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 78991 invoked from network); 29 May 2019 18:38:50 -0000 Received: from unknown (HELO NAM03-CO1-obe.outbound.protection.outlook.com) (40.92.7.88) by pb1.pair.com with SMTP; 29 May 2019 18:38:50 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=outlook.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=R565ocswAULOclkSBA9f5IQ3KGwIBR4Ey4/mwFuyqyk=; b=rFDNrZkRJsa0K7R8WQYLm4BZ5b7s+zRRzv3rO+D+eqgH0XJ+3cZwyeiEYqOj6zmmUoN+UEqs2MEvyjOqPxjluojeCIEwiZx5B3SITfKbZtyibJkuexsVi25+ezw+PWGkbXXEQGr66TgboM0usdRa1Jbd19ckan2Hq4iYeENh36+iz8+jISLX7ATnZQopK+iRDAJOCkjqXzNzd/O7dUJi/sGNLa8Q9iC0R46ihfWD85EUSX7tb0xmdK1FyT79F6PRCYAZ0FBAY1ngJiNKejcEUI5JAcGmLxE3JpSde9MQnHI52eYGRD6c1d0cjr3y6HYZ20vyj0YpSYC8iMBBE08uCA== Received: from BY2NAM03FT020.eop-NAM03.prod.protection.outlook.com (10.152.84.52) by BY2NAM03HT015.eop-NAM03.prod.protection.outlook.com (10.152.85.5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.1922.16; Wed, 29 May 2019 15:48:15 +0000 Received: from MWHPR06MB2861.namprd06.prod.outlook.com (10.152.84.51) by BY2NAM03FT020.mail.protection.outlook.com (10.152.84.224) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.1922.16 via Frontend Transport; Wed, 29 May 2019 15:48:15 +0000 Received: from MWHPR06MB2861.namprd06.prod.outlook.com ([fe80::bc99:7f29:71ac:9104]) by MWHPR06MB2861.namprd06.prod.outlook.com ([fe80::bc99:7f29:71ac:9104%4]) with mapi id 15.20.1922.021; Wed, 29 May 2019 15:48:15 +0000 To: "G. P. B." , PHP internals Thread-Topic: [PHP-DEV] Re: [RFC] Numeric Literal Separator Thread-Index: AQHVCzD4Zg3fV6zubk+OJkqTtyX3naaAoYJugABd7YCAAB+7gIAAsIkAgAAN64CAACfkgIAACTIAgAATS/Y= Date: Wed, 29 May 2019 15:48:14 +0000 Message-ID: References: <1858501.VmE1D5L3rF@mcmic-probook> <39e8e5ad-6685-9406-68ac-1fb1edbeb537@fischer.name> , In-Reply-To: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-incomingtopheadermarker: OriginalChecksum:52BD6DC2732BC683F7BF5460186B534EB5B3FB4BD32954FD143F984744DDDC5C;UpperCasedChecksum:A8D6B9A8E2D6EBFC675A1BD7D9EBD3D2B2E635C8C344742C87BCD770CD3F68F3;SizeAsReceived:7192;Count:43 x-ms-exchange-messagesentrepresentingtype: 1 x-tmn: [6pVsGqlmgcGtG/ZyMsBn0cVXNT0UWWsH] x-ms-publictraffictype: Email x-incomingheadercount: 43 x-eopattributedmessage: 0 x-microsoft-antispam: BCL:0;PCL:0;RULEID:(2390118)(5050001)(7020095)(20181119110)(201702061078)(5061506573)(5061507331)(1603103135)(2017031320274)(2017031322404)(2017031323274)(2017031324274)(1601125500)(1603101475)(1701031045);SRVR:BY2NAM03HT015; x-ms-traffictypediagnostic: BY2NAM03HT015: x-microsoft-antispam-message-info: bOg3s27QGNBBWGVi3ANEF8/KkDfSoTzH4m78U1CJsp/9j8UcH4gtxHP7FMfEDki+18DJfEdD0eeBL2lu/f1U8qYkbjUlBLbiriR6BrvX8BHbTF5C7R2HoZ2GLoDvRXe60yEKy2fEXOJEr1GwdRzo71b5wZjaAkIPPo8o7CMyhSD1WRHDBFiF+q6X1I7re5nw Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-CrossTenant-Network-Message-Id: 0a015081-fcfa-4f0a-50bf-08d6e44d0fe9 X-MS-Exchange-CrossTenant-rms-persistedconsumerorg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-CrossTenant-originalarrivaltime: 29 May 2019 15:48:14.9226 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Internet X-MS-Exchange-CrossTenant-id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY2NAM03HT015 Subject: Re: [PHP-DEV] Re: [RFC] Numeric Literal Separator From: theodorejb@outlook.com (Theodore Brown) On Wed, May 29, 2019 at 6:34 AM G. P. B. wrote:= =0A= =0A= > I share the same concerns as Rowan Collins=0A= =0A= From my reading of Rowan's email, he was making a general point that=0A= new features can have a cost of added complexity for users. He then=0A= clarified "I don't personally think that applies here".=0A= =0A= > I'm really not a fan of the RFC in general. Also I think those kind=0A= > of magic numbers should be constants with meaningful names, and it=0A= > that case you could just compute them by adding powers of ten.=0A= > E.g. DISCOUNT_IN_CENTS =3D 1 * 10^5 + 3 * 10^4 + 5 * 10^3;=0A= =0A= Actually I think this example highlights why numeric literal=0A= separators can be very helpful for improving readability and=0A= preventing mistakes. First, which of these is faster to read?=0A= =0A= ```php=0A= $discount =3D 1 * 10**5 + 3 * 10**4 + 5 * 10**3;=0A= // or=0A= $discount =3D 135_00;=0A= ```=0A= =0A= Secondly, your example of adding powers of 10 is off by an order=0A= of magnitude! It's equivalent to $1,350.00, not $135.00, but this=0A= isn't very obvious when reading the complex expression.=0A= =0A= Of course, if you prefer the first approach you can continue using it.=0A= But personally I find the second approach quicker to read and less=0A= prone to mistakes.=0A= =0A= > Moreover I feel that people may misread numbers like that if people=0A= > use different groupings. E.g. 1_0000_0000_0000; by skimming rapidly=0A= > I could think it's a billion(10^6) when in reality it's a trillion=0A= > (10^9). Even if maybe some countries are moving away from the=0A= > grouping digits in groups of 4.=0A= =0A= Even with the different grouping, it's faster for me to count the=0A= digits in that number than if it had no separator at all.=0A= =0A= > I'll probably vote against it but that's only my opinion.=0A= =0A= That's up to you. But even if you don't personally have a need for=0A= the feature, I think it's worth considering that there are valid use=0A= cases for it which can help improve code readability and clarify intent.=0A= =0A= Best regards,=0A= Theodore=