There is a confusing concept about each one. You use this all the time, you know exactly how they work, but until the moment to try to write about it, you get asking yourself: "parameter or argument"? To this list, I added options too. Why? Because parameter is often used when you are reading man pages.
You can read the differences between then in Wikipedia or in other places, but I'll try a simpler, more visual approach. There are two main contexts where you use these terms: in 1) programming and in 2) command-line interface.
Programming Context
-
(formal) parameter: is the variable in a function definition or in a prototype declaration, and is used to denote type. Example:
/* function definition, so a and b are parameters */ int func(int a, int b) { ... }
-
(actual) argument: is the value or expression in a function call, and is used to denote an instance. Example:
/* this is a function call, 3 and (x + y) are arguments */ func(3, x + y);
Command-line Interface Context
In this context, the terms CLI argument or parameter are used interchangeably. The intent is to detail some terminology, not all possibilities, such as --longoptions
and other combinations. Take for example the following:
$ cmd -xarg something
-x
is an option, called also switch or flag, which is a parameter/CLI (command-line interface) argument-xarg
(or-x
arg) is an option plus its option argument (sometimes optional), which is a parameter/CLI argumentsomething
is a parameter/CLI argument-xarg something
(the whole thing aftercmd
) is also a parameter/CLI argument
It's a logic exercise.