Homework 3 Solution

$30.00 $24.00

(28 pts) Using the C++ programming language, indicate the binding time (language design, language implementation, compilation, link, run, etc.) for each of the following attributes. Justify your answer. The variable declaration that corresponds to a certain variable reference (use) The range of possible values for integer numbers The meaning of char The address of a…

5/5 – (2 votes)

You’ll get a: zip file solution

 

Categorys:
Tags:

Description

5/5 – (2 votes)
  1. (28 pts) Using the C++ programming language, indicate the binding time (language design, language implementation, compilation, link, run, etc.) for each of the following attributes. Justify your answer.

    1. The variable declaration that corresponds to a certain variable reference (use)

    2. The range of possible values for integer numbers

    3. The meaning of char

    1. The address of a local variable

    2. The address of a library function

    3. The referencing environment of a function passed as a parameter

    4. The total amount of memory needed by the data in a program

  1. (24 pts) Can a language that uses dynamic scoping do type checking at compile time? Why? Can a language that uses static scoping do type checking at run time? Why?

  1. (24 pts) Does Scheme use static or dynamic scoping? Write a short Scheme program that proves your answer.

  1. (24 pts) Consider the following pseudo-code:

x : integer; — global

procedure set_x (n : integer)

x := n;

procedure print_x

write_integer (x);

procedure foo (S, P : procedure; n : integer)

x : integer;

if n in {1,3}

set_x(n);

else

S(n);

if n in {1,2}

print_x;

else

P;

— main program

set_x(0); foo (set_x, print_x, 1); print_x; set_x(0); foo (set_x, print_x, 2); print_x; set_x(0); foo (set_x, print_x, 3); print_x; set_x(0); foo (set_x, print_x, 4); print_x;

Assume that the language uses dynamic scoping. What does this program print if the language uses shallow binding? Why? What does it print with deep binding? Why?

Note: At exactly one point during execution in the deep binding case, the program will attempt to print an uninitialized variable. Simply write a “?” for the value printed at that point.

Homework 3 Solution
$30.00 $24.00