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:
“Do you call it doubting to write down on a piece of paper that you doubt? If so, doubt has nothing to do with any serious business. But do not make believe; if pedantry has not eaten all the reality out of you, recognize, as you must, that there is much that you do not doubt, in the least. Now that which you do not at all doubt, you must and do regard as infallible, absolute truth.”
—Charles Sanders Peirce (18391914)