Re: Thousands Separator
| From: | Stuart Dallas | Date: | Mon, 19 Jan 2015 11:30:19 +0000 |
| Subject: | Re: Thousands Separator | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-324271@lists.php.net to get a copy of this message | ||
On Friday, Jan 16, 2015 at 8:33 pm, Jennifer <jennifer@superiorshelving.com>, wrote:
On Jan 16, 2015, at 11:51 AM, Jim Lucas wrote:
> Could you explain the use of what you're describing/requesting?
>
> And how number_format would not work in its place.
I'm talking about entering large numbers in the code. If I have a constant, e.g.
$num = '123456789';
it would be nice to enter it as:
$num = '123_456_789';
just to make it easier to read. As I mentioned, you can do that in Perl. The underscore takes the
place of commas only for readability. It's not a deal breaker, but it sure would be nice! :)
What you have proposed above is incredibly bad language design, but only because you’re not
proposing what you think you are.
Supporting automatic removal of underscores in the following is a reasonable feature:
$num = 123_456_789;
Doing the same in the following is not:
$num = ‘123_456_789’;
This implies that PHP will detect that the string contains a number with _s in place of thousands
separators, and will ignore the _s. This is NOT a good idea and will lead to unintended
consequences. The first example above says that PHP will accept and ignore _s in numeric literals,
which is a very different proposition with no unintended side effects.
Precision is very important when designing language features.
-Stuart
--
Stuart Dallas
3ft9 Ltd
http://3ft9.com/