0

In the third last paragraph at page number 26 of the ebook "The C Programming Language" the author(s) say,

"We will generally use parameter for a variable named in the parenthesized list in a function. The terms formal argument and actual argument are sometimes used for the same distinction."

And in the hard copy of the book that I am having, on the second last paragraph of page number 25 the author(s) say,

"We will generally use parameter for a variable named in the parenthesized list in a function definition, and argument for the value used in a call of the function. The terms formal argument and actual argument are sometimes used for the same distinction."

If I understand it correctly, it means whatever the value(or variable) is used in the call of a function, that is called argument. And whatever is written in the paranthesis of the definition of a function, that is called parameter. E.g. in the following code:

#include<stdio.h>

int func(int j)
{  
    return j;  
}

main()  
{  
    int k=5;  
    printf("The argument = %d", func(k));  
}  

the parameters are declared by the line int func(int j). The argument given, through which main() and func(int j) communicate is k.

Now, on the page number 30 of the book(both, the ebook and the hard copy) the authors state,

"main and getline communicate through a pair of arguments and a returned value. In getline, the arguments are declared by the line

int getline(char s[], int lim);"

As I understand, char s[] and int lim are parameters, because they are written in the definition of the function getline, not in the call of that function, so my question is,

Why have the authors used the word argument in the second paragraph of page number 30?

  • "In getline, the [formal] arguments are declared by the line" – CodeCaster Jan 22 '15 at 12:25
  • @CodeCaster main and getline communicate through a pair of arguments and a returned value They are not using the word formal argument. They are using the word argument. – user106313 Jan 22 '15 at 12:43
  • And they are using the word "generally" in "We will generally use parameter". – CodeCaster Jan 22 '15 at 12:45
  • 3
    So it took them four pages to make a typo/mistake/let out a word on purpose. I'm not sure what your question is. – CodeCaster Jan 22 '15 at 12:47
  • 1
    Possible duplicate of Is there a difference between arguments and parameters? – gnat May 11 '16 at 1:39
3

English (and I presume other languages as well) has a lot of words which can be used in a generic sense, but are no longer correct in a context which requires more distinction. For example, you can use the word "goose" to refer to a goose of any gender or age when speaking in the more common generic sense, but if a distinction must be made, a male goose is properly called a gander, and a baby goose is properly called a gosling.

"Argument" and "parameter" are two such words. You can use "argument" in a more loose context to refer to either an argument or a parameter, but in certain circumstances it's helpful to be able to distinguish between them precisely. Those circumstances are rare enough that many programmers don't learn the distinction for years, if ever.

Don't ask me why English is that way. It wasn't designed for ease of parsing.

  • What are the meanings of Argument and Parameter in English and how are they similar? – user106313 Jan 22 '15 at 14:38
1

The term "argument" is often used rather loosely to refer to either actual arguments or formal arguments without giving the actual or formal adjective. Most often, the context makes it clear if actual arguments or formal arguments/parameters is meant.

In this case, it should be clear that the authors meant formal arguments or parameters. As to why they didn't use parameters is pure speculation. It can be a simple oversight or a deliberate choice because it made the text flow better.

  • Could you explain, what do you mean by it made the text flow better. – user106313 Jan 22 '15 at 12:48
  • @user31782: I mean that the word 'argument' just sounded better to them when writing this part than the word 'parameter'. – Bart van Ingen Schenau Jan 22 '15 at 12:51
  • "Klingon function calls do not have 'parameters' - they have 'arguments' - and they ALWAYS WIN THEM." (#7 of Top 12 things likely to be overheard if you had a Klingon Programmer:) – gnat Jan 22 '15 at 12:55
  • If we can use argument for parameter whenever we want, then why was the concept of parameter vs. argument developed? – user106313 Jan 22 '15 at 13:14
  • @user31782: Because people got tired of mixing up actual arguments with formal arguments and they needed a different term for one of them perhaps? – Bart van Ingen Schenau Jan 22 '15 at 13:19
0

First, let's recap:

  • "parameter = the variable's name"
  • "argument = the expression we pass to the function"

Note too that "argument" isn't the variable's name. Therefore, it is everything else. Figuratively speaking, you can think of "argument" as a pipe/line. A line that connects the text in the source code holding the "actual argument" with the text in the source code naming the "formal argument".

This pipe has a type. It represent a C cast. A cast is defined by the source type and the destination type.

When they tell you that "the arguments are declared by the line int getline(char s[], int lim)" they tell you that here's the definition of the pipe (which is "argument"): its target type is "char []" (and source type can be anything).

  • Could you explain you answer in detail with examples. I don't understand this line "A line that connects the text in the source code holding the "actual argument" with the text in the source code naming the "formal argument"." I also do not know what a cast is. – user106313 Jan 22 '15 at 13:49
  • @user31782: If you don't know what a cast is, you need to read the rest of the book, or at least the next 20 pages. – Blrfl Jan 22 '15 at 14:11
  • @Blrfl Ok ${}{}{}{}{}{}$ – user106313 Jan 22 '15 at 14:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.