Answered step by step
Verified Expert Solution
Question
1 Approved Answer
For the rest of the questions, we will use the following programming language. Let s call it PL 3 0 5 . PL 3 0
For the rest of the questions, we will use the following programming language. Lets call it PL PL has the following syntax for the declaration and call of the procedures:
####################################################
# This is how we write a line comment.
def foo: #This line assigns the value of the parameter z to the variable yWhatever integer foo is called with, y will hold that value,
int x # this is how we declare a variable no initialization possible
def fooz: # Here, within the body of foo we define a nested procedure called foo that takes one parameter, z Procedures or functions within other functions are often used for encapsulation or to create closures.
int y #Within the body of foo this declares another integer variable named y
y z # his line assigns the value of the parameter z to the variable y Whatever integer foo is called with, y will hold that value.
printy # we can print the value of a variable
end foo # end of foo
x # assign to the variable x
call foox # The foo procedure then calls foo passing x as an argument. Since x is foo will print
end foo # end of foo
Question Suppose that you just started to learn PL and you would like to find out whether the dynamic scoping or the lexical scoping is used in PL To find this out, you design the following PL program:
####################################################
def foo:
# LINE
def foo: # foo is defined in foo
# LINE
# LINE
call foo # foo calls foo
end foo
def foo: # foo is also defined in foo
# LINE
end foo
# LINE
call foo # foo calls foo
printx # this print will tell
end foo
####################################################
Complete the dotted lines ie LINE LINE LINE LINE LINE above in such a way that, when foo is called, the print statement at the end of foo prints if PL uses dynamic scoping, and it prints if PL uses lexical scoping.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started