Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is "Call By Name"?

I'm working on a homework assignment where we are asked to implement an evaluation strategy called "call by name" in a certain language that we developed (using Scheme).

We were given an example in Scala, but I don't understand how "call by name" works and how it is different to "call by need"?

like image 852
forellana Avatar asked Jun 03 '10 02:06

forellana


1 Answers

Call-by-need is a memoized version of call-by-name (see wikipedia).

In call-by-name, the argument is evaluated every time it is used, whereas in call-by-need, it is evaluated the first time it is used, and the value recorded so that subsequently it need not be re-evaluated.

like image 88
Doug Currie Avatar answered Oct 14 '22 06:10

Doug Currie