Starting from:

$30

CS 381 Homework 6 – Scope and Parameters

CS 381 Homework 6 – Scope and Parameters
Submit a pdf file containing the solutions in Canvas.

Problem 1. Runtime Stack
Consider the following block. Assume static scoping and call-by-value parameter passing.
Demonstrate the computations that take place during the evaluation of this block, that is, give a
sequence of lines each showing the complete runtime stack with all activation records after each
statement or function call. For recursive calls use one stack onto which a new activation record is
pushed on for each recursive function call.
Problem 2. Static and Dynamic Scope
Consider the following block. Assume call-by-value parameter passing.
a) Draw the runtime stack after each line executes under static scoping. What value assigned to z in
line 12?
b) Draw the runtime stack after each line executes under dynamic scoping. What value assigned to
z in line 12?
CS 381 Homework 6 – Scope and Parameters
Problem 3. Parameter Passing
Consider the following block. Assume dynamic scoping.
a) Draw the runtime stack after each line executes given that both parameters a and x are passed
using Call-by-Name. What are the values of y and z after line 13 executes?
b) Draw the runtime stack after each line executes given that both parameters a and x are passed
using Call-by-Need. What are the values of y and z after line 13 executes?

More products