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
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 nameStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started