Week 9- Implementing Subprogram Flashcards
What are formal parameters?
Variables defined by a subprogram to accept values.
What is the general process of a subprogram call and return?
Save status, pass parameters, execute, restore status, and return.
What are actual parameters?
Real values passed to the subprogram.
What are stack-dynamic local variables?
Variables allocated/deallocated on the runtime stack.
What is an overloaded subprogram?
A subprogram with the same name but different parameter lists.
What is ad hoc polymorphism?
Subprograms operate on different types based on actual parameters.
What is a coroutine?
A subprogram with multiple entry points allowing cooperative multitasking.
What is in an activation record instance (ARI)?
Caller status, parameters, return address, return value, temporaries.
What are the two parts of a simple subprogram’s AR?
Code part and non-code part (local variables and data).
What is the first action a caller must perform in the linkage process?
Create an activation record instance.
What does the caller do to the current program unit’s execution status?
Saves it.
What is passed to the called subprogram after parameters?
The return address.
What is the first action in the callee’s prologue?
Save the old EP in the stack as the dynamic link.
What does the callee do to the execution status of the caller?
Restores it.
What happens to the local variables in the callee’s prologue?
They are allocated.
What happens to out-mode parameters during the callee’s epilogue?
Their values are moved to the corresponding actual parameters.
What happens to the stack pointer in the callee’s epilogue?
It is restored to the value of the current EP minus one.
What does ARI stand for?
Activation Record Instance.
What additional ARI information is saved in a recursive call?
Return address and dynamic link.
What is the dynamic chain in the context of ARIs?
The collection of dynamic links.
How is an ARI for a nested subprogram found?
By finding the correct ARI in the stack and using the local offset.
What is a static chain?
A chain of static links pointing to static parents.
Define static depth.
The depth of a subprogram’s nesting in the outermost scope.
What is a local offset?
The distance from the beginning of an ARI.
What is a block in programming?
A user-specified local scope.
What advantage do blocks provide?
Variables cannot interfere with others of the same name.
Which has faster references: deep or shallow access?
Shallow access.
What is deep access?
Searching through ARIs of active subprograms for variables.
What is shallow access?
Using separate stacks for each variable name.
What are parameterized abstract data types also known as?
Generics or templates.
What is encapsulation in programming?
A construct that bundles the data and the methods that operate on the data, restricting direct access to some of the object’s components.
What is abstraction?
A representation of an entity that includes only its most significant attributes.
What are the two types of abstraction fundamental in computer science?
Process abstraction and data abstraction.
What is an ADT?
An Abstract Data Type is a type whose implementation is hidden and can only be manipulated through a defined set of operations.
What is a user-defined ADT?
An ADT where the representation is hidden, and only operations defined in the type’s definition are allowed.
What are the advantages of hiding data in an ADT?
Increased reliability, reduced name conflicts, and enhanced modifiability.
What is an example of a language-defined ADT?
Floating-point type.
What are the benefits of having a single syntactic unit for type definitions and operations in ADTs?
It organizes the program better and enhances modifiability.
How do access controls like private and protected enhance encapsulation?
They restrict access to the internal details of the data structures.
Can abstract types be parameterized?
Yes
Why is it important to separate the specification of a type from its implementation?
To allow modifications to the implementation without affecting the clients using the type.
What is a key feature of a stack ADT?
It only allows access to the data element at the top.
What operation is commonly used as a getter for the top element in a stack?
pop().