Hacker News new | ask | show | jobs
by zombot 360 days ago
"has no parameters" is not the same as "cannot take arguments". Defining `int main()` does not stop the runtime from passing the usual 3 arguments (typically named argc, argv, envp), it only means that no parameters are bound to those arguments. Technically it's no problem to have a C function ignore its arguments by not binding parameters. Way too many programmers seem to not understand the difference between parameter and argument.

https://stackoverflow.com/questions/156767/whats-the-differe...

2 comments

> "has no parameters" is not the same as "cannot take arguments".

In C I guess that's true. In languages more concerned with compile-time rigor, it often isn't. Not a correction, just an observation.

Surely part of the problem is having a distinct term and handling for parameters passed to functions. What is the point? It seems confusing with no upside.
Do you find the difference between abstract and concrete confusing? Or the difference between container and contents? Is that a pointless distinction with no upside?
I do agree these are useful concepts to distinguish, but I don't get the connection to the topic at-hand. To me, there is just the function signature. I don't see a benefit to referring to passed values as distinct from received values. To my ear "argument" and "parameter" are perfect synonyms.
> referring to passed values as distinct from received values.

That’s not the distinction being made by those terms.

“Parameter” refers to a named variable in a function definition.

“Argument” refers to an actual value that’s passed to a function when it’s called.

It’s exactly the same as the distinction between variables and values (which you probably see the use for), just applied to the special cases of function signatures and function calls.

(As an aside, in the lambda calculus this relationship becomes a perfect equivalence: all variables are parameters and all values are arguments.)

Well, I certainly would not interpret the terms that way, but you do you.
It's the standard definition in a software development context, which you can find all over the place. Here are some examples:

> "Parameters are named variables declared as part of a function. They are used to reference the arguments passed into the function."

-- MDN, https://developer.mozilla.org/en-US/docs/Glossary/Parameter

> "A parameter is a special kind of variable used in a function to refer to one of the pieces of data provided as input to the function. These pieces of data are the values of the arguments with which the function is going to be called/invoked."

-- Programming Fundamentals, https://press.rebus.community/programmingfundamentals/chapte...

> "Parameters refer to the variables listed in a function's declaration, defining the input that the function can accept. Arguments, however, are the actual values passed to the function when it is called, filling the parameters during execution."

-- https://www.geeksforgeeks.org/computer-science-fundamentals/...

While you might be tempted to "do you" and use your own idiosyncratic definitions, I advise against it, since it makes it difficult for you to understand what others are saying, and vice versa.

There is nothing to "interpret". In programming, those terms are defined that way.
lol, it's not a "you do you" thing, that's what they're actually named, "parameters" and "arguments" have distinct objective definitions in this context and those are it. In this specific case it's you who's using made up words for concepts that others already have a specific name for.