Machine-translated by Google. Questions are authored in English.
Top

Discussion

Which of the following parameter passing methods works with the idea that the argument is not evaluated until its actual use as a parameter in the called program ?

  • A.Pass by Value-Result
  • B.Pass by Name
  • C.Pass by Value
  • D.Pass by Reference

Answer: B

The method is Pass by Name.

In call by name, introduced in Algol 60, the actual argument is not evaluated at the call. It is passed unevaluated (in practice as a small routine, a thunk), and re-evaluated in the caller's environment each time the parameter is used in the called procedure. This is the idea behind lazy evaluation.

Pass by value evaluates the argument once at the call and copies the value. Pass by reference passes the address of an already-evaluated variable. Pass by value-result copies the value in at the call and copies it back on return.

No comment is present. Be the first to comment.
Loading…

Post your comment

Please log in or register to post a comment.