Call-by-something



         


Parameters are a way of allowing the same sequence of commands to operate on different data without re-specifying the instructions.

For example, take the following list of instructions:

  1. Take an object.
  2. Break it into little pieces.
  3. Throw it away.

In this case, the object that the instructions are to operate on is the parameter. If we give this process a name like Destroy, then referring to Destroy followed by the desired object will perform the actions on that object.

For instance:

  1. Destroy rock.
  2. Destroy cake.
  3. Destroy car.

will apply the instructions above to a rock, cake, and car respectively.

The sequence of instructions is usually made into a subprogram and the object to operate on is specified while invoking the subprogram. The actual value given to a subprogram while invoking it, viz. rock, cake or car is called an actual parameter or an argument and the placeholder within the subprogram used to describe the operations on the argument is called a formal parameter or simply a parameter.

[Top]

Calling conventions

Parameters can be passed to subprograms in several ways:

On a more conceptual level, one may distinguish between parameters for input, for output or both. Virtually all older programming languages regard output and both as identical, but more modern languages as C# make a distinction.

On the technical level, input parameters are implemented as by value, while the other two types are implemented as by reference.





  View Live Article   This article is from Wikipedia. All text is available under the terms of the GNU Free Documentation License