Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why do programming languages use commas to separate function parameters?

Tags:

It seems like all programming languages use commas (,) to separate function parameters.

Why don't they use just spaces instead?

like image 973
Emanuil Rusev Avatar asked Aug 15 '10 16:08

Emanuil Rusev


People also ask

Why are commas used in coding?

In the C and C++ programming languages, the comma operator (represented by the token , ) is a binary operator that evaluates its first operand and discards the result, and then evaluates the second operand and returns this value (and type); there is a sequence point between these evaluations.

Why do we use semicolon in C language?

Role of Semicolon in C: Semicolons are end statements in C. The Semicolon tells that the current statement has been terminated and other statements following are new statements. Usage of Semicolon in C will remove ambiguity and confusion while looking at the code.

Why do you think that we need syntaxes in a code?

Syntax in computer programming means the rules that control the structure of the symbols, punctuation, and words of a programming language. Without syntax, the meaning or semantics of a language is nearly impossible to understand.

Why do we still need multiple types of programming languages instead of combining them?

Conclusion. To sum it up, the main reason why there are many programming languages out there is that different problems require different tools to solve them. Each programming language has certain features and characteristics that make it suitable for specific tasks.


1 Answers

Absolutely not. What about this function call:

 function(a, b - c);

How would that look with a space instead of the comma?

 function(a b - c);

Does that mean function(a, b - c); or function(a, b, -c);? The use of the comma presumably comes from mathematics, where commas have been used to separate function parameters for centuries.

like image 59
Carl Norum Avatar answered Sep 28 '22 21:09

Carl Norum