Question: One important question about by-result parameter passing that was not mentioned is this: when does the language system compute the Ivalue of the actual parameter?

One important question about by-result parameter passing that was not mentioned is this: when does the language system compute the Ivalue of the actual parameter? (The Ivalue of the actual parameter is the memory location to which the final value of the formal parameter is written.) You might have assumed that this would be computed, like a by-reference parameter, before the called method executes. But since it is not needed until the called method returns, its computationcould be delayed until it is needed, like a by-name parameter. Ada does it the early way, while Algol W does it at the last minute.

Here is an example that illustrates the difference:

void f(int [ ] A) {

int i = 0;

g (i, A [i]);

}

void g (by-reference int i, by-result int j) {

j = 2;

i = 1;

j = 3;

}

For each of these two different interpretations of by-result parameter passing, explain what happens when f calls g. In particular, say exactly what happens when any change is made to i or A

One important question about by-result parameter passing that was not mentioned is

Consider the following Java like code fragment: int[]A* 12, 3); Where f is defined as follows: void f (int x int y, int z) int temp tempi For each of the given parameter passing methods, what are the values of j, k, AC01, and AC1] upon return from f? Fill in the table. ax y and z are passed value b.x y and z are passed by reference. 20 3 C) x y and z are passed by value-result d) x is passed by value and y and z are passed by reference 210 3 e) x, y and zare passed by name Consider the following Java like code fragment: int[]A* 12, 3); Where f is defined as follows: void f (int x int y, int z) int temp tempi For each of the given parameter passing methods, what are the values of j, k, AC01, and AC1] upon return from f? Fill in the table. ax y and z are passed value b.x y and z are passed by reference. 20 3 C) x y and z are passed by value-result d) x is passed by value and y and z are passed by reference 210 3 e) x, y and zare passed by name

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!