Sie sind auf Seite 1von 3

TALLER • Lenguajes de Programación José Montes & Arnulfo Torres

REVIEW QUESTIONS
1. In Java and C#, how long can a name be?
Names in Java and C# have no length limit
2. How can a variable be characterized?
A variable can be characterized as a sextuple of attributes: (name, address, value, type,
lifetime, and scope)
3. What is deallocation of a memory cell?
Deallocation is the process of placing a memory cell that has been unbound from a variable
back into the pool of available memory
4. After language design and implementation, what are the four times bindings can take
place in a program?
compile time, load time, link time, and run time.
5. How is a reference to a nonlocal variable in a static-scoped program connected to its
definition?
A reference to a non-locally variable in a static-scoped language with nested subprograms
requires a two-step access process:
1. Find the correct activation record instance
2. Determine the correct offset within that activation record instance.

PROBLEM SET
1. Which of the following identifier forms is most readable? Support your decision.

FirstName
First_Name
firstname

First_Name is the most readable, because it doesn’t have any problem whit sensitives
cases, also because the following identifier doesn’t use caps lock.
2. Consider the following JavaScript skeletal program:

// The main program


var x;
function sub1() {
var x;
function sub2() {
. . .
}
}
function sub3() {
. . .
}

Assume that the execution of this program is in the following unit order:
main calls sub1
TALLER • Lenguajes de Programación José Montes & Arnulfo Torres

sub1 calls sub2


sub2 calls sub3

a. Assuming static scoping, in the following, which declaration of x is the correct one
for a reference to x?
i. sub1: sub1
ii. sub2: sub1
iii. sub3: main
b. Repeat part a, but assume dynamic scoping.
i. sub1: sub1
ii. sub2: sub1
iii. sub3: sub1

3. Consider the following Python program:


x = 1;
y = 3;
z = 5;
def sub1():
a = 7;
y = 9;
z = 11;
. . .
def sub2():
global x;
a = 13;
x = 15;
w = 17;
. . .
def sub3():
nonlocal a;
a = 19;
b = 21;
z = 23;
. . .
. . .
List all the variables, along with the program units where they are declared, that are visible in
the bodies of sub1, sub2, and sub3, assuming static scoping is used.
1. x = 1 (main),
y = 9 (sub1),
z = 11 (sub1),
a = 7 (sub1);

2. x = 15 (sub2),
TALLER • Lenguajes de Programación José Montes & Arnulfo Torres

w = 17 (sub2),
a = 13 (sub2),
y = 9 (sub1);

3. x = 15 (sub2),
b = 21 (sub3),
a = 19 (sub1),
z = 23 (sub3),
w = 17 (sub2);

4. x = 15 (sub2),
b = 21 (sub3),
a = 19 (sub1),
z = 23 (sub3),
w = 17 (sub2);

Das könnte Ihnen auch gefallen