News for hackers. Stuff that matters.
Re:Ask HN: Why can't I write a int literal like 2,333? by fiedzia on Tuesday March 07, 2017 @04:21AM (#13809233)
Because:

a) comma has already defined meaning so it could be ambiguous - it would mean tuple (2,333) in python for example

b) even if its not the case, its easy to confuse it with floats, and you do not want apply local numerical conventions to code and discover one day that all your ints are floats because some setting was different

c) you can write it as 2_333 in growing number of languages

Re:Ask HN: Why can't I write a int literal like 2,333? by Piskvorrr on Tuesday March 07, 2017 @04:27AM (#13809248)
Oh yeah, let's have more of the ambiguity that CSVs have: is it a comma between arguments? Is it a decimal comma? Is it a thousands separator? Is my locale correct for parsing this? What was the author's intended and actual locale?

On the other hand, what improvement does this bring? ... "it is supposed to look pretty."

Re:Ask HN: Why can't I write a int literal like 2,333? by CarolineW on Tuesday March 07, 2017 @04:22AM (#13809237)
What syntax would you then use for calling a function with multiple parameters? Function f takes two ints and I call it like this: f(3,456,789)

What are its parameters?

Re:Ask HN: Why can't I write a int literal like 2,333? by brudgers on Tuesday March 07, 2017 @11:06AM (#13811448)

  f (3,456 789)
or

  f(3 456,789)
or

  f(3,456,789)
depending on intent. I mean the requirement of a common as a separator seems superfluous -- particularly in languages like Python which rely heavily on semantic whitespace.
Re:Ask HN: Why can't I write a int literal like 2,333? by AnimalMuppet on Tuesday March 07, 2017 @01:04PM (#13812870)
True, but now you're asking for a change in function call syntax, just so you can print integers in a format that some people find more readable. That seems like a bit overkill...
Re:Ask HN: Why can't I write a int literal like 2,333? by brudgers on Tuesday March 07, 2017 @01:43PM (#13813277)
I've been reading Steele's Common Lisp: the Language and one of the ideas I'm currently working out is based on how it talks about users and not programmers. I think this is an effect of the fact that using a Lisp on a Lisp Machine was just 'using the computer' like using DOS on a DOS machine or CPM on a CPM machine. Emacs Lisp is another example of a language conceived as a way of using a computer (in its case editing text) rather than for writing programs.

Anyway, baked into the question is the idea of localization (comma or dot) and under the computing language as a means of using (rather than programming) a computer, that makes perfect sense under modern practice. Even my phone does it.

I'm not expecting Python to change its function call syntax, and if I were able to change one thing on that scale it would be C's null terminated strings (in a New York minute). On the other hand, breaking changes to Python are not without precedent.

Re:Ask HN: Why can't I write a int literal like 2,333? by mailslot on Tuesday March 07, 2017 @04:30AM (#13809259)
In C++1y/C++14, you can use the apostrophe. i.e. 2'333

They took a backward compatible approach by using a symbol that's not already used for other operations, like "," or "." or ";" The grammar would be non-trivial or too restricted otherwise, IMO.

Re:Ask HN: Why can't I write a int literal like 2,333? by bengunnink on Tuesday March 07, 2017 @08:52AM (#13810281)
Recent Java versions did something similar, allowing underscore characters, e.g., 7_000_000.
Re:Ask HN: Why can't I write a int literal like 2,333? by bjourne on Wednesday March 08, 2017 @07:14AM (#13819711)
Factor (http://factorcode.org/) supports that syntax:

  3,400,000,000 3400000000 =
  9,312 9312 =
  4,294,967,296 4294967296 =
  
It's pretty useful for writing large numbers.
Re:Ask HN: Why can't I write a int literal like 2,333? by svisser on Tuesday March 07, 2017 @01:12PM (#13812955)
In Python you can do this:

1_000_000

https://www.python.org/dev/peps/pep-0515/