Concepts of Programming Languages Chapter 10
Name : Erland
NIM : 1601218035
Lecturer : Tri Djoko Wahjono, Ir., M.Sc. (D0206)
Assignment : Concept of programming languages Chapter 10
Review Questions
1. What is the definition used in this chapter for simple subprogram?
Answer :
the subprograms cannot be nested and all local variables are statics.
2. Which of the caller or callee saves execution status information?
Answer :
It can be done by both of em
4. What is the task of a linker?
Answer :
The task of a linker is to find the files that contain the translated subprograms referenced in that and load them into memory
5. What are the two reasons why implementing subprograms with stack-dynamic
local variables
local variables
Answer :
the compiler must generate code to cause the implicit allocation and deal-location of local variables.recursion adds the possibility of multiple simultaneous activations of a subprogram
6. What is the difference between the activation record and an activation
record instance?
record instance?
Answer :
activation record : the data it describes are relevant only during the activation, or the execution of the subprogram.
Activation record instance: a concrete example of an activation record, a collection of data in the form of an activation record.
7. Why are the return address, dynamic link, and parameters placed in the
bottom of the activation record?
bottom of the activation record?
Answer :
It's because the entry must appear first.
10. Define static chain, static_depth, nesting depth and chain_offset
Answer:
Answer:
-Static chain is a chain of static links that connect certain activation record instances in the stack-Static depth is an interger associated with a static scope that indicated how deeply it is nested in the outermost scope.-Nesting depth is the length of the static chain needed to reach the correct activation record instance for a nonlocal reference to a variable -Chain_offset is the length of static depth of the subprogram containing the reference to and declaration for X.
11. What is an EP and what is its purpose?
Answer :
EP points at the base, or the first address of the activation record instanceof the main program. EP is used to access parameters and local variables during the execution of subprograms
15. Explain the two methods of implementing blocks
Answer :
– deep access– shallow access
16. Describe the deep-access method of implementing dynamic scoping
Answer :
The dynamic chain links together all subprogram activation record instances in the reverse of the order in which they were activated. The dynamic chain is exactly what is needed to reference nonlocal variables in a dynamic-scoped language.