Spring 2001, CSE 428: Quiz 4.4 - 8 Feb 2001


Please write your Name, Student ID, and Section at the top of the page.
  1. [Pts 2]

    A function which uses call by name can be (only one answer please)

    1. called only with variable actual parameters
    2. non-strict
    3. implemented only by using a stack-based machine
    4. evaluated at compile-time

  2. [Pts 3]

    For each of the following parameter passing methods, say how many times the actual parameter will be evaluated. The answer has to be either : (a) never / (b) exactly once, at the moment of the call / (c) at most once, during the execution of the body / (d) an arbitrary number of times (depending on the body), during the execution of the body / (e) once at the moment of the call and an arbitrary number of times during the execution of the body

    1. call by name     (d)
    2. call by need     (c)
    3. call by value     (b)

  3. [Pts 3]

    Consider the following procedure and fragment of code in C++ like, where y is declared globally:

       void p(int ... x){ x = x+1; y = y+2; }
       ...
       y = 1;
       p(y);
       cout << y; 
       ...
    
    What is the value printed by the instruction cout << y; under each the following parameter passing methods:

    1. call by value     3
    2. call by value-result     2
    3. call by reference     4

  4. [Pts 2]

    The lifetime of a local variable is

    1. the entire execution of the program
    2. during the activation of the block (or procedure, or function) in which it is declared
    3. during the activation of the block (or procedure, or function) in which it is used
    4. until it is destroyed explicitly with a delete instruction