Chapter 9 Flashcards
Subprograms are process abstraction or data abstraction?
Process abstraction
What are the general characteristics of subprograms?
-Single entry point
-Caller is suspended until function returns
-Control always returns to the caller when finished
What are the basic definitions for subprograms?
definition - What the function does
call - Where the function is actually called
header - void function(parameter)
What are formal parameters?
Parameters in the subprogram header
What are actual parameters?
The parameters that are passed to the function call
What are positional parameters?
They bind formal parameters to their corresponding actual parameters via position
What are keyword parameters?
The name of a formal parameter with the actual parameter bound to it
How are positional/keyword parameters the same/different?
Both types bind formal and actual parameters. They differ by how they choose to bind them: position versus name
How do procedures and functions differ?
Functions are meant to return values, and procedures are meant to modify parameters
What are the design issues for subprograms?
-Choice of parameter passing methods
-Will parameters be type checked?
-Can subprogram definitions be nested?
-Can subprograms be overridden or generic?
What is a referencing environment?
A set of variables declared as local in a subprogram
What are the 3 parameter passing modes?
-In
-Out
-Inout
How are the parameter passing modes implemented?
-In: Pass-by-value
-Out: Pass-by-result
-Inout: Pass-by-value-result, pass-by-reference, pass-by-name
How do common languages support those parameter passing modes?
They use a runtime stack and copy/paste values to and from it
How are subprograms passed as parameters to subprograms?
-The environment of the call statement that enacts the passed subprogram (shallow binding)
-The environment of the definition of the passed subprogram (deep binding)
-The environment of the call statement that passed the subprogram as an actual parameter (ad hoc binding)