CS 334
Programming Languages
Spring 2000

Assignment 5
Due Friday, 3/17/2000


  1. In early FORTRANs (i.e., I to 77) there was usually no checking of code for recursive calls. Instead at execution time the recursive call was made, but the program later fell into an infinite loop. Based on your knowledge of the implementation of subroutine calls in FORTRAN, explain why this happens. Design a mechanism which would allow the program to detect such recursive calls and abort. Your mechanism should also detect mutually recursive or indirectly recursive calls. (It is sufficient to have a run-time rather than compile-time mechanism - i.e., figure out how to detect when this happens at run-time.)

  2. Do problem 23 on page 244 of Louden.

  3. A block is like a procedure body which occurs in-line in a program. That is, it is composed of a series of declarations followed by some executable code. However it may not be called like a procedure, it is only executed when the program counter enters the first statement of the block. Please explain why the static and dynamic links have the same values for blocks.

  4. In class we discussed the use of a run-time stack of activation records for procedure calls in block-structured languages. In the interpreter you wrote last week there was no explicit use of a run-time stack. Your (recursive) interpreter for PCF provides similar support for activation records (though PCF is simpler than block-structured languages because there are no local variables and only one parameter for each function call). Explain how your interpreter provides a stack-like support for activation records by explaining how the environment changes during the evaluation of the following expression:

    	((if is_zero(((fn y => pred y)1)) then succ else pred)
    		((fn y => (pred(pred y)))8))
    

Back to:
  • CS 334 home page
  • Kim Bruce's home page
  • CS Department home page
  • kim@cs.williams.edu