On Sat, Feb 02, 2008 at 02:01:59PM -0800, [EMAIL PROTECTED] wrote:

Statically scoped means that the variable binding can be determined at
compile time.  Dynamic scoping means the scoping is determine by the call
flow at runtime.  Few languages support dynamic scoping, although it is
easy in common lisp, and possible in Scheme.

When you say "compile time" that means "evaluation time" inside
an interpreter like mit-scheme right?

No, I mean at compilation time.  Very different from evaluation time.

If you think of a batch compiler (which mit scheme can be), compile time is
when you compile your source file to an executable.  Evaluation time
happens later, when someone runs the program.  They might not even be
happening on the same computer.

The 'eval' construct kind of blurs this distinction, since it does both
steps for immediate expressions.

Thanks.  That cleared it up.  I find it amusing that the fluid-let SRFI
was killed. :)

Most scheme implementations have a very hard time implementing it.  It's
very hard to do.

A message passing style of programming in Scheme would involve functions
that always end with a tail call.

A tail call just means a function calls itself at the end?

No, that's only one case of a tail call.  It doesn't have to call itself,
and it doesn't have to be at the end.

The easiest way to figure it out is to ask yourself the question: "When
this call returns, what do we do with the result?"  If your answer is that
we just return it to our caller, then it is a tail call.  If we have to
remember some other stuff and then do something with the result, it is not
a tail call.

  (define (foo x)
    (if (< x 5)
        (bar (+ x 1)
        (+ (baz x) 1))))

In the above code, the call to 'bar' is a tail call, since the result from
bar is the very result we're returning from foo.  The call to 'baz' is not
tail recursive, since we have to do something with the result of the call
before we return.  The tail call is not the last one.

Tail recursion requires tail calls, but tail calls do not have to be
recursive.

David

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

Reply via email to