What does "dummy argument" mean?

Question Detail: 

What is does it mean when an argument to a function is called a dummy argument? I have not encountered this term outside Fortran, is it a general term in computer science? What would be examples of arguments passed as dummy and not passed as dummy?

I found this definition, which I am not sure that I understand, but it sounds like a dummy argument is a variable that is passed by reference, in which case in Fortran all variables are dummy variables? (confused)

Edit: I just run into the following essay which helped me to understand better Fortran's argument/function calling teminology: Dortor Fortran: I've come here for an argument

Asked By : Kyss Tao
Best Answer from StackOverflow

Question Source : http://cs.stackexchange.com/questions/3469

Answered By : jmad

"Dummy" as "unused"

In general (not in Fortran) a dummy argument is an argument that will not be used by the body of the function.

For example, in the following function, z is a dummy argument but x and y are not.

int f(int x, int y, int z) {   return (x + y); } 

They can be used for several reasons:

  • depending on another argument or some configuration, the argument will be used (not dummy) and sometimes it won't (dummy) but the programming setting imposes to pass an argument anyway. In that case, you can usually pass anything to the function, i.e. NULL or 0, depending on the setting;

  • the argument is no more needed, but you have to give one for backward compatibility reasons;

  • the function does not take any argument (it can be called a procedure) but the setting imposes to give at least an argument. You can find this in unpure functional programming languages but in general it is not called "dummy" because the type (unit in ocaml) suggests it.

"Dummy" in Fortran and Pascal

In Fortran and Pascal, and probably in your case, there is a more obscure notion of passed-object dummy argument that I have failed to comprehend. But it seems to concerns more the specification than the actual argument-passing procedure. (Some explanations: link 1 with both languages, link 2 in French).

I don't know if this notion is still used.

"Dummy" as "bound"

I would not advise this terminology in any case, but "dummy variable" can mean "bound variable" but this notion is more of a math and computer science thing.

No comments

Powered by Blogger.