Question: Procedure A has static depth 3 and defines a variable which is visible in a nested subprocedure B . The nesting depth between procedure A
Procedure A has static depth 3 and defines a variable which is visible in a nested subprocedure B. The nesting depth between procedure A and procedure B is 1 (that is, B is directly nested inside A). What is the static depth of B?
| 3 | ||||||||||||||||||||||||||||||||||||||
| 1 | ||||||||||||||||||||||||||||||||||||||
| 4 | ||||||||||||||||||||||||||||||||||||||
| 2 Consider the following program: procedure Main is A : Integer; B : Integer; procedure Sub1(X: Integer) is B, C : Integer; begin B := 2; C := 3; A := B + C; end; begin A := 1; B := 1; Sub1(B); end; What is the reference to B in the expression A : = B + C (in terms of chain-offset/local offset)?
In a static scoped language that uses static chaining as an implementation technique, references to non-local variables can be represented as:
When the system uses static chain to access nonlocal variables, which of the following are true?
|
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
