There is no clear consensus on what is the right way to pass parameters. It is clearly most important that whatever language you are programming in, you should endeavor to understand its paradigms. This lab is not exhaustive in covering all the possibilities. We hope that it will provide you with a good foundation for experimenting and asking the right questions when you start work with a new language. In this chapter, we briefly mention some language features (idiosyncracies?) not mentioned elsewhere.
Our implementation of call-by-reference forces the user to always pass references. If you define a procedure using proc-by-ref then you are asking for trouble if you pass it arguments that are not boxes.
Some languages do let you pass non-references to by-reference procedures. In such cases, the value of the actual argument is placed in a new location, and assignments to this location made by the called procedure have no effects visible in the calling procedure.
Another issue that you might like to think about is the feasibility of combination of protocols. Does call-by-need mesh well with call-by-reference in any meaningful way? Ask yourself such questions and try to answer them to yourself.
With call-by-text and call-by-need, delayed evaluation can cause unexpected problems.
In the above, the meaning of (:= x y) will vary depending upon the calling protocol. Make reasonable assumptions. Define a variable i to have the value 0. Now make a call to (swop i arr[i]).(define swop (proc-by-??? (a b) (LOCALVAR ((temp 'notyet)) (:= temp a) (:= a b) (:= b temp))))
What will be the resulting values of i and the array arr if the parameter passing protocol is: