[UMN logo]

CSCI 5106: Programming Languages
Spring 2006, University of Minnesota
Assignment 6
Comments on Grading


General Remarks

The maximum grade for this assignment was 12 points, the first problem carrying 4 points, the second 6 and the third 2. The highest score on this homework was 11.5, the standard deviation was 2.52 and the mean was 7.3.


Problem 1

This question was testing if you understood the essential differences between the different parameter passing mechanisms. Having to put all this together in one example needs you to utilize both the similarities and the differences, so this is an especially good test of your understanding. Some of you seem to have misunderstood this purpose and provided separate programs for each pair. This defeats the purpose of the assignment---we have already seen examples in class that bring out the differences individually---and the problem description in the book is very clear for this misunderstanding to be deemed unacceptable. If you did this, therefore, you lost points. Other reasons for losing points were (a) not providing the results of your programs, (b) providing wrong results (even if the program differentiated between different parameter passing mechanisms) and (c) providing a program that did not really differentiate all the relevant cases.

Since some of you seem still to have difficulties with this kind of question, here is a solution. The difference between call-by-value (CBV) and call-by-reference (CBR) is in the isolation between the formal and actual parameters in one case and the identification of these in the other. Now, in most situations CBR produces similar results to call-by-value-result (CBVR) and call-by-name (CBN), so if one part of our example remains within these situations then it would also serve to differentiate CBV from all the others. A swap like program fragment would do very well for this.

CBVR differs from CBR only in the presence of aliasing and we can extend our swap example suitably to bring this out. If this part does not differentiate between lazy and eager address calculation then its behavior under CBN would be the same as that under CBR and this would therefore also distinguish between CBN and CBVR. Finally, distinguishing between CBR and CBN involves exploiting differences between lazy and eager address calculations. Putting all these things together, we might write a code fragment such as the following:

int x;

void  swap(int i, int j, int k)
{ int temp;
  temp = i;
  i = j;
  j = temp;
  x = 5;
  k = 3;
}

int main()
{ int y; 
  int A[2];

  x = 0; y = 1; A[0] = 2; A[1] = 2;
  swap(x,y,A[y]);
}
C syntax has been used here but, of course, C does not have all the different parameter passing mechanisms to match the different interpretations we want of this code. Make sure to check the results with the different mechanisms with this example and also to understand how it encapsulates the thought process I describe above that leads to this solution.

If you have questions on your individual program, please see Xiaochu. She would be happy to explain the problems with your solution or, if you can convince her that she did not understand your solution properly, to correct your grade. With a problem like this, where everyone's answer is different, it is possible that your solution may not have been understood as completely as it should have been.


Problem 2

The answer to this question is discussed at length in Section 5.7 of the text so I will not repeat it here. If you have not read this section, you will be well advised to do this now. The question needed you to really discuss details such as how variable access is actually determined at runtime, what information the compiler extracts for this and how, how access links are actually calculated at runtime, how results are returned, how return addresses are communicated, etc. At the end of this course, the expectation is that you know a fair amount about program structure in general and also have some knowledge about how things might be implemented. Procedure activation is an important topic about which you should understand details.

The scoring for this problem was broken up as follows: 2 points for depicting or describing stack snapshots in a comprehensive way, 2 points for explaining the control and access link maintenance and 2 points for explaining the compiler support for and the runtime activity involved in resolving variable reference.


Problem 3

Again the answer to this question is pretty much present at the end of Section 5.7. The discussion expected here includes the maintenance of the display array, the way variables are accessed, and the information provided by compiler to support the needed run-time behaviour.


Last updated on April 18, 2006 by gopalan@cs.umn.edu and xqi@cs.umn.edu