

Why do most programming languages use commas in argument lists? - miked

Does anyone know the answer to this? I've been looking at these things for over thirty years, and it just occurred to me to ask this question. Note that argument tokens are (almost) always either composed of contiguous dark space or enclosed in matching delimiters (i.e., ", ', (). [], etc.)<p>Here are some possible answers, and problems I see with each:<p>-- They help separate arguments in argument lists.<p>==&#62; Not for me. Apparently not for Lisp, Arc, 
Scheme, and Clojure people either. In parameter lists that allow types as well as parameter names, commas make sense, as they help separate the groups. But in argument lists (and parameter lists without types) they just add noise, IMHO.<p>-- All the languages do it, therefore it's expected, and therefore, well, all the languages do it.<p>==&#62; Lisp, Scheme, and Clojure don't, though Clojure treats them as whitespace and lets you put them where you want.<p>-- Math books have been doing this for ages, so it's a natural follow-on.<p>==&#62; This makes some sense, but it really only shifts the problem around. Why do <i>they</i> do it?<p>This isn't the most earthshaking issue, but commas in arg lists are noisy.
======
jacquesm
Because we do it in regular language as well ?

It says "there is more coming, I'm not finished yet".

In COBOL you even use the '.' to indicate end-of-section, just like in written
language.

The trouble with that is that on a line printer those '.'s really don't stand
out very much and if you forget one you're toast :)

~~~
miked
Interesting answer, and goes to my suspicion that "this is the way we've
always done it" is part of the answer. But see the comments above.

 _The trouble with that is that on a line printer those '.'s really don't
stand out very much and if you forget one you're toast_

That's not the half of it. Many years ago the US launched a satellite, part of
whose control was done by a Fortran program. Well, one of the developers used
a single period in a loop header where he should have had a comma.
Unfortunately, in Fortran that was syntactically valid. Problem was, it was
hard on the printer he used to see the difference. So the satellite and a
bunch of US taxpayer money took a trip to the center of the sun. Ouch.

------
ajuc
About math books:

because in math space can mean multiply: f(ax - 1 b - 3 c y z) is not as clear
as f(ax - 1, b - 3 c, y, z).

~~~
miked
Good point. People sometimes use expressions with operators as arguments.

My take now is that, because comments are required for cases such as the
above, they require them everywhere. What should happen is that they be
optional.

Also, it just occurred to me that, while Lisp et al. don't use commas, they do
use parentheses to bracket subexpressions, so they don't have a problem with
the issue you just cited.

------
RiderOfGiraffes
In handwritten mathematics the end of one expression and the start of the next
is not always obvious. Putting the comma is almost a requirement.

Remember also that the original ForTran language definitions didn't bother
with spaces because it was hard to tell from the handwritten code (from which
it was transcribed) whether there were spaces or not.

------
Daishiman
If your only category distinctions lie between Lisp and non-Lisp languages,
then yeah, pretty much all languages do it. The real question is if you
consider another symbol to be more appropiate. Since the comma correlates well
to the purpose in question in natural languages, it's the most obvious choice.

------
Semiapies
This is more of a rant against non-Lisp style than a question.

------
balding_n_tired
Tcl doesn't.

