opisdfjsfdajk Flashcards
Definition of a Subprogram
Interface to and the actions of the subprogram abstraction
Subprograms in Major Languages
Executable: Python
Nonexecutable: Most other Languages
Ruby: Can be called without an object, like a function
Lua: anonymous
Subprogram call
Explicit request that the subprogram be executed
Parts of a subprogram
Header: First Part, includes name, kind of subprogram, and formal parameters
Profile (Signature): Number, order, types of its parameter
Protocol: Parameter profile and its functions, return type
Formal Parameter
Dummy variable listed in subprogram
Formal Parameters in Major Languages
C++, Python, Ruby PHP: can have default values
Categories of Subprograms
Procedure: Collection of statements that define parameterized computations
Functions: Resemble procedure but are modeled on math functions
Dynamic Stack Local Vars
ADV: Support for recursion; Storage for locals is shared among some subprograms
DIS: Allocation/Deallocation, initialization time, indirect addressing, Subprograms cannot be history-sensitive
Static Local Vars
ADV: Opposite of Stack Dynamic
DIS:
Static/Stack Dynamic in major languages
Stack Dynamic: Locals of most languages, Methods in Java, C++, Python, C#
Static: can be declared in C based languages
Semantic Models
In mode: actual –> formal
Out mode: formal –>actual
Inout Mode: actual <–> formal
Implementation Models
(Pass-by- )
value (In mode)
result (out mode)
value-result (inout mode)
reference (inout mode)
name (inout mode)
Parameter passing methods of major Languages
C: Pass by Value/reference
C++: Pass-by-reference
Java: (Non-object) Pass by value (objects) pass by reference
Fortran 95+: in, out, or inout mode
C#: Pass-by-value, reference can be called with ref
Python and Ruby: Pass by assignment
Type Checking
Non in Fortran and OG C
Required in Java and Pascal
Ansi C, C++ is a choice
Not required in Perl, Javascript, PHP
Not possible: Python Ruby
Shallow Binding
Environment of the call statement that enacts the passed subprogram
Dynamic-Scoping
Deep Binding
Enviorment of the definition of the passed subprogram
Static-Scoped