Dale - Computer Science Illuminated 279

Dale - Computer Science Illuminated 279 - gram is called, a...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
Arguments The identi- fiers listed in parentheses on the subprogram call; sometimes they are called actual parameters. 252 Chapter 8 High-Level Programming Languages Figure 8.6 Passing parameters identifiers are called arguments . The arguments represent actual variables in the calling unit with which the subprogram is to work. You can think of a parameter as being a dummy identifier that is used within a subprogram. When a subprogram is called, the calling unit sends the names of the actual identifiers to the subprogram. The action in the subprogram is defined using the parameters. When the action takes place, the arguments are substituted one by one for the parameters. The substitu- tion can be done in several ways, but the most common is by position. The first argument substitutes for the first parameter, the second argument substitutes for the second parameter, and so on. The substitution mechanism acts like a message board. When a subpro-
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: gram is called, a list of the arguments is given to the subprogram (put on the subprograms message board). The arguments tell the subprogram where to find the values it is supposed to use. When a parameter is used in the body of the subprogram, the subprogram accesses it through a relative position on the message board. That is, the subprogram looks for its first parameter in the first position on the message board and for its second parameter in the second position on the message board. See Figure 8.6. There must be the same number of arguments in the call as there are parameters in the subprogram heading, and the parameters and arguments must match up in both position and data type. Because the arguments and parameters are matched by position, their names dont have to be the...
View Full Document

This note was uploaded on 01/13/2011 for the course CSE 1550 taught by Professor Marianakant during the Fall '10 term at York University.

Ask a homework question - tutors are online