+ 1

Arguments or parameters?

This is still confusing to me, whether I have to call them parameters or arguments. Learning PHP I read that: When you define a function, the variables that represent the values that will be passed to it for processing are called parameters. However, when you use a function, the value you pass to it is called an argument. Does this mean they are actually both the same and the only difference is in using the variables?

16th Jun 2019, 5:57 AM
Jaap Timmer
Jaap Timmer - avatar
6 Respuestas
+ 4
The more precise terminologies are, -- Formal parameters: These are merely variable (objects) lists inside a pair of parenthesis in front of the function name (as part of the function signature when defining it) informing the compiler the expected inputs of the function. Example: void f( int parameter_1, int parameter_2 ) { // implementation goes here... } This tells us the function `f` would accept two integer input through "receiving arguments" that later on will happen by "calling" the function `f`, then the two parameters would get initialized by them to use in the body of `f()`. -- Actual arguments: Actual values that must be passed to a function when calling it. void f( int parameter_1, int parameter_2 ) { // implementation goes here... } void g() { int argument_1 = 1; int argument_2 = 2; f( argument_1, argument_2 ); // calling }
16th Jun 2019, 7:32 AM
To Seek Glory in Battle is Glorious
To Seek Glory in Battle is Glorious - avatar
+ 3
Parameters are defined when defining a function, but argument are made when you actually call the function function A(num1, num2) -> parameters A(2, 9) -> arguments
16th Jun 2019, 6:07 AM
Airree
Airree - avatar
+ 3
parameter: a box argument: what you put in there
16th Jun 2019, 6:32 AM
HonFu
HonFu - avatar
+ 1
A simple example clarifies so much more than text only. Thank you!!
16th Jun 2019, 6:08 AM
Jaap Timmer
Jaap Timmer - avatar
+ 1
Sometimes is necessary to know "technical words" in order to understand. That three words are math words: function, argument, parameters. You will get use to it. Just keep researching. Sometimes there is no need for examples because words are a good way to communicate ideas and concepts. This kind of situations are common in programming. Happy coding!
16th Jun 2019, 7:15 AM
Jonas
Jonas - avatar
+ 1
True. Thx Jonas!
16th Jun 2019, 7:16 AM
Jaap Timmer
Jaap Timmer - avatar