What is "Call By Name"?

forellana picture forellana · Jun 3, 2010 · Viewed 25.7k times · Source

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"?

Answer

Doug Currie picture Doug Currie · Jun 3, 2010

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.