Call By Name
Simula supports call by name so the Jensen's Device can easily be implemented. However, the default transmission mode for simple parameter is call by value, contrary to ALGOL which used call by name. The source code for the Jensen's Device must therefore specify call by name for the parameters when compiled by a Simula compiler.
Another much simpler example is the summation function which can be implemented as follows:
Real Procedure Sigma (k, m, n, u); Name k, u; Integer k, m, n; Real u; Begin Real s; k:= m; While k <= n Do Begin s:= s + u; k:= k + 1; End; Sigma:= s; End;The above code uses call by name for the controlling variable (k) and the expression (u). This allows the controlling variable to be used in the expression.
Note that the Simula standard allows for certain restrictions on the controlling variable in a for loop. The above code therefore uses a while loop for maximum portability.
The following:
can then be implemented as follows:
Z:= Sigma (i, 1, 100, 1 / (i + a) ** 2);Read more about this topic: Simula, Sample Code
Famous quotes containing the word call:
“Although I will inherit darkness
I will keep dialing left to right.
I will struggle like a surgeon.
I will call quickly for the glare of the moon.
I will even dial milk.”
—Anne Sexton (19281974)