Take the 2-minute tour ×
Computer Science Stack Exchange is a question and answer site for students, researchers and practitioners of computer science. It's 100% free, no registration required.

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

share|improve this question

2 Answers 2

up vote 9 down vote accepted

"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.

share|improve this answer
    
My understanding (note: I know French and programming language semantics but not Fortran) is that “dummy argument”, in all 3 links in your Fortran/Pascal section, means an argument that is a local name for an object passed by reference. –  Gilles Sep 9 '12 at 18:52

A function is a well defined as: relation between a set of inputs and a set of permissible outputs. A dummy variable would be any input that had no effect on the output.

In "C" the time function takes a pointer to a time_t object as input. As this pointer is only used to get output it could be considered a "dummy variable".

share|improve this answer
    
wouldn't it be more accurate to call it an output variable? In fact, in some settings (e.g. in C#), it would actually be given the "out" keyword to label it as an out parameter. –  Joe Sep 11 '12 at 22:41

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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