Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:105808 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 92650 invoked from network); 31 May 2019 00:01:44 -0000 Received: from unknown (HELO mail-vk1-f177.google.com) (209.85.221.177) by pb1.pair.com with SMTP; 31 May 2019 00:01:44 -0000 Received: by mail-vk1-f177.google.com with SMTP id v69so1069015vke.0 for ; Thu, 30 May 2019 14:11:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=wr6rACJq9oI+YVV9Qi9b2KI6WmhmHI0L60RAJ6lkHz8=; b=HPIckjSkUVT5FL0CvqDfWmvg1JUT8KWqP02gQP6c6jsrL2bVUYjeqw97xxOAW9MJS7 zZQjt1kOT09Yl5T5nr8HPB/wZFc6cIpjMKsuoZSAhriXQeQRksylvFJ3GYNGFkr2F5D5 eQGs6n0APXx3Jrt7aJ2qqWa+RH+9NDUtQcRFbtNkBt4km+KNIi7NoCwxr9ByRyw40+gU OOIab2ECLFcY+rsltz8Q/uaFeopuLdo1Xt3q4upOFhS3xpl3G17ARgcPx6++oRXMRD2F nsNB8JoXTvC9O9jeKZKAEJ88W7XKMIQiL5bk+j4/APYFQgUC6YMDja6puQrkQ0KzbImg Mb4A== 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:from:date :message-id:subject:to:cc; bh=wr6rACJq9oI+YVV9Qi9b2KI6WmhmHI0L60RAJ6lkHz8=; b=HIDt7VSZ7h9OU++BcKKPC4MQWBktjtuOHjqxV3Dma9oE+iX9KvrjvSNxsvW5sdGvnN N6QiAnDPAcMVJPSSJFOKQ9WMqme1n8jjHhOO1kCj6dInjsscxgFSAhTVLiDn9PCS9vt/ OLZfOJHt74OFUea1ynq3w9VxKbEyWY5PSjbXhxtDeFtjGhFcOXhlqAQoGaKbne76QI2k m4p6XF7Rh17Mtwgu1oHtmhRNZficAYgzO1ZjnfX+u0fkMmqiSbFsbDin+ynLSFVEYc5Z uQRDJw8tVce4U3VaKH3lF4G0i2LRSP2TEi4ZQqzg1DJrEhenKF6rbq5IKVOElrwdoaPE 1tGw== X-Gm-Message-State: APjAAAWHkMhFkR75f0TfQox+p5/MLpd7AI2jg84VDmB4CGtWaQpBWw5C yg1HjkI75jAGSofQH8VWLKaVlhQ0uoCm90v3gOA= X-Google-Smtp-Source: APXvYqydJiy4jd0o/qLLgdDw929DRI0/lQsf87foLwAHoCTrVfT9o4UpjZtM0o5Vt3PFKLDIye/SZtjrswK3qlxRUD8= X-Received: by 2002:a1f:1507:: with SMTP id 7mr1550731vkv.15.1559250688227; Thu, 30 May 2019 14:11:28 -0700 (PDT) MIME-Version: 1.0 References: <1858501.VmE1D5L3rF@mcmic-probook> <39e8e5ad-6685-9406-68ac-1fb1edbeb537@fischer.name> In-Reply-To: Date: Thu, 30 May 2019 23:11:19 +0200 Message-ID: To: Theodore Brown Cc: PHP internals Content-Type: multipart/alternative; boundary="000000000000633c0c058a21571b" Subject: Re: [PHP-DEV] Re: [RFC] Numeric Literal Separator From: george.banyard@gmail.com ("G. P. B.") --000000000000633c0c058a21571b Content-Type: text/plain; charset="UTF-8" On Wed, 29 May 2019 at 17:48, Theodore Brown wrote: > On Wed, May 29, 2019 at 6:34 AM G. P. B. wrote: > > > I share the same concerns as Rowan Collins > > From my reading of Rowan's email, he was making a general point that > new features can have a cost of added complexity for users. He then > clarified "I don't personally think that applies here". > > > I'm really not a fan of the RFC in general. Also I think those kind > > of magic numbers should be constants with meaningful names, and it > > that case you could just compute them by adding powers of ten. > > E.g. DISCOUNT_IN_CENTS = 1 * 10^5 + 3 * 10^4 + 5 * 10^3; > > Actually I think this example highlights why numeric literal > separators can be very helpful for improving readability and > preventing mistakes. First, which of these is faster to read? > > ```php > $discount = 1 * 10**5 + 3 * 10**4 + 5 * 10**3; > // or > $discount = 135_00; > ``` > > Secondly, your example of adding powers of 10 is off by an order > of magnitude! It's equivalent to $1,350.00, not $135.00, but this > isn't very obvious when reading the complex expression. > Oh well I suppose that'll teach me trying to write some code on my phone. Of course, if you prefer the first approach you can continue using it. > But personally I find the second approach quicker to read and less > prone to mistakes. > I mean I don't really use that as I personally don't have a problem counting digits nor do I use massive numbers. There are also other ways to go about it but that's not really the deal here. > Moreover I feel that people may misread numbers like that if people > > use different groupings. E.g. 1_0000_0000_0000; by skimming rapidly > > I could think it's a billion(10^6) when in reality it's a trillion > > (10^9). Even if maybe some countries are moving away from the > > grouping digits in groups of 4. > > Even with the different grouping, it's faster for me to count the > digits in that number than if it had no separator at all. > IMHO using a power of ten in this example would be the "best" solution. But like before that's not really the question here. > > I'll probably vote against it but that's only my opinion. > > That's up to you. But even if you don't personally have a need for > the feature, I think it's worth considering that there are valid use > cases for it which can help improve code readability and clarify intent. > I'm just fundamentally against it but if I'm in the minority it will pass and it's not like I'm going to make a fuss about it behind added to the language. Best regards George P. Banyard --000000000000633c0c058a21571b--