Re: Thousands Separator

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Friday, Jan 16, 2015 at 8:33 pm, Jennifer <jennifer@xxxxxxxxxxxxxxxxxxxx>, 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/

[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux