What is call-by-name? Does Scala and Java support call-by-name? What is the difference between call-by-value and call-by-name function parameters?
Answer Posted / Shivaji Choudhary
Call-by-name is a parameter passing mechanism where an argument is passed as a reference to a subroutine, allowing the subroutine to evaluate the argument only when it is actually needed (i.e., the first time the argument's value is referenced inside the subroutine). Scala supports call-by-name through its by-name parameters, while Java does not have native support for call-by-name. The main difference between call-by-value and call-by-name is that call-by-value arguments are evaluated before being passed to a function (and then the result is passed), while call-by-name arguments are only evaluated when needed within the function.
| Is This Answer Correct ? | 0 Yes | 0 No |
Post New Answer View All Answers