Question
The Algol60 definition states the following substitution rule for pass by name: 1. Any formal parameter . . . is replaced, throughout the procedure body,
The Algol60 definition states the following substitution rule for pass by name:
1. Any formal parameter . . . is replaced, throughout the procedure body, by the corresponding actual parameter, after enclosing this latter in parentheses wherever syntactically possible. Possible conflicts between identifiers inserted through this process and other identifiers already present within the procedure body will be avoided by suitable systematic changes of the formal or local identifiers involved.
2. Finally, the procedure body, modified as above, is inserted in place of the procedure statement and executed. If the procedure is called from a place outside the scope of any nonlocal quantity of the procedure body the conflicts between the identifiers inserted through this process of body replacement and the identifiers whose declarations are valid at the place of the procedure statement or function designator will be avoided through suitable systematic changes of the latter identifiers (Naur [1963a], p. 12).
(a) Give an example of an identifier conflict as described in rule 1.
(b) Give an example of an identifier conflict as described in rule 2.
(c) Carry out the replacement process described in these two rules on the program in Figure 10.4
Here is the Figure 10.4:
(1) #include
(2) int i;
(3) int p(int y)
(4) { int j = y;
(5) i++;
(6) return j+y;
(7) }
(8) void q(void)
(9) { int j = 2;
(10) i = 0;
(11) printf("%d ", p(i + j));
(12) }
(13) main()
(14) { q();
(15) return 0; (16) }
Step 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