On Thu, Jan 24, 2008 at 10:37:17AM -0800, Brad Beyenhof wrote:

So, am I getting this right?

*Applicative order: evaluates each argument in order (both operator
and operands are "arguments" in this sense), only looking at an
argument farther down the line if it's called for.
*Normal order: expand every argument to primitive data or functions,
then reduce the expression by combining the primitives.

Not quite.

  "only looking at an argument farther down the line if it's called for"

is incorrect.  This is the feature you get from normal order.  Applicative
order looks and fully evaluates every argument before invoking/expanding
the procedure itself.  If it takes forever to expand one of your arguments
it will never call the procedure, even if the argument isn't used.  This is
why the call to test hangs.  Even though test doesn't use its second
argument in this case, Scheme evalutes all of the arguments before calling
it.  The evaluation of (p) never terminates.

You can think of normal order as only using the arguments when they are
needed.

I think the terms are kind of confusing, and prefer the terms lazy vs
strict.  A strict functional language (scheme) evaluates the arguments to a
function before calling the function.  A lazy functional language (haskell)
only evaluates the arguments when they are needed by the called function.

Dave

--
[email protected]
http://www.kernel-panic.org/cgi-bin/mailman/listinfo/kplug-lpsg

Reply via email to