Chapter 9 Flashcards
What are the three general characteristics of subprograms?
Each subprogram has a single entry point.
The calling program unit is suspended during the execution of the called subprogram, which implies that there is only one subprogram in execution at any given time.
Control always returns to the caller when the subprogram execution terminates.
What is a subprogram call?
It is the explicit request that a specific subprogram.
What is a subprogram definition?
It describes the interface to and the actions of the subprogram abstraction.
What characteristic of Python subprograms sets them apart from those of other languages?
It is that function def statements are executable.
How do Ruby methods differ from the subprograms of other programming languages?
Ruby methods are often defined in class definitions but can also be defined outside class definitions.
If a Ruby method is called without a receiver, self is assumed.
If there is no method by that name in the class, enclosing classes are searched, up to Object, if necessary.
What is the feature of Lua functions?
Although they’re anonymous, they can be defined using syntax that makes it appear as though they have names.
What are function declarations called in C and C++? Where are the declarations often placed?
Function declarations in C and C++ are called prototypes and they are often placed in header files.
Name one pure functional programming language that does not have mutable data.
Haskell
What are positional parameters?
The correspondence betweenn actual and formal parameters-or the binding of actual parameters to formal parameters-is done by position: The first actual parameter is bound to the first formal parameter and so forth.
Give an example of a language that allows positional parameters in addition to keyword parameters.
Python
What is the use of a default value?
It is used if no actual parameter is passed to the formal parameter is passed to the formal parameter in the subprogram header.
What is the rule of using a default parameter in C++?
The default parameters must appear last, because parameters are positionally associated.
Once a default parameter is omitted in a call, all remaining formal parameters must have default values.
What is the rule for accepting variable parameters in C# methods?
The parameters have to be of the same type.
What language allows array formal parameters?
Ruby
What is an ellipsis?
(…) Can be treated as an array or as a list of values that can be assigned to a list of variables.