Re: Re: [RFC] Numeric Literal Separator
| From: | Theodore Brown | Date: | Wed, 29 May 2019 16:49:28 +0000 |
| Subject: | Re: Re: [RFC] Numeric Literal Separator | ||
| References: | 1 2 3 4 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-105798@lists.php.net to get a copy of this message | ||
On Wed, May 29, 2019 at 9:03 AM Côme Chilliet <come@opensides.be> wrote:
> > My understanding from the RFC is that that the grouping is not
> > relevant, the
_ is stripped regardless.
> >
> > Am I wrong?
>
> No you’re not, the RFC allows grouping as the coder wants.
>
> Which is why I think it may cause problems because the way the
> coder wants to group digits and the way easier for me to read is
> not always the same.
>
> As Christoph M. Becker states there are already problems like this
> with choice of names for variables and code style and such, but
> until now numbers were a safe place that always looks the same.
Numbers don't always look the same, though. They can already be
written using hexadecimal, octal, decimal, binary, or exponential
notation.
Furthermore, as a workaround for the lack of numeric literal
separators, some programmers end up writing numbers as complex
expressions like 1 * 10**5 + 3 * 10**4 which can actually
make them more difficult to read.
> If people want to see big numbers broke up in groups of 3 I would
> expect their IDE to do this on numbers for them.
It isn't always desirable to group big numbers the same way, though.
For example, a programmer may want to write 13500 as 135_00 or
13_500 depending on whether or not it represents a financial
quantity stored as cents.
> But I do get the point of the RFC for hexa and bit masks.
Yes, this is another case where it can be useful to group by a
varying number of digits depending on how a value is being used
(e.g. nibbles, bytes, or words).
So while it's conceivable that someone could use numeric literal
separators to write a number in a less readable way, does this
mean that the many good PHP developers shouldn't have the option
to use this feature to improve readability?
Sincerely,
Theodore