On Sat, Dec 29, 2007 at 02:57:25PM -0800, [EMAIL PROTECTED] wrote:
On Fri, Dec 28, 2007 at 12:01:25PM -0800, David Brown wrote:
There's a lot more to learn from the book than just Scheme.  It covers
fairly diverse areas of computer science, making use of Scheme's
flexibility.

I love that Scheme is a lean clean Lisp but I don't like that it has
some things that are incompatible with Lisp and that Lispers don't agree
with.  "Closures" is an example I hear about.  I don't know Lisp, Scheme
or closures.  If I learn Scheme will it mess up my brain to learn Lisp?

There are a handful of differences between Lisp and Scheme.  Some are
philosophical and others are just annoying.  Lisp is a fairly large
language, which means that implementations are likely to agree better on
what is in standard libraries.  The Scheme standard is very small, so
libraries will diverge more.

Your "closures" comment is the biggest difference.  Scheme is strictly
lexically scoped, meaning it uses closures to provide access to free
variables.  Lisp supports dynamic scoping which basically uses global
variables, and when you enter a dynamic scope, it saves the variables you
change, and then restores them on return.

I guess I could see why someone would consider the Lisp dynamic scoping to
be an advantage, since it is more flexible, but it also can make for some
very hard to find bugs (global variables change for the duration of their
use in a new scope).  I would argue that the lexical scope of Scheme is
what it is supposed to do, and lisp's dynamic scoping is a hack to make it
work to be able to implement it at the time (remember lisp is much older
than scheme, 50's vs 70's).  You should be using lexical scoping in Lisp
anyway :-)

The strictly lexical scoping of scheme allows for call/cc, which is kind of
like goto on steroids.

Scheme requires implementation to do non-stack-expanding tail recursion,
which means iteration can always be written as recursion.  This is also the
case with ML family languages.  This eliminates the need for a bunch of
iteration constructs, but can take some getting used to.

Learning scheme won't mess up your brain to learn Lisp.  In fact, it will
probably make you a better Lisp programmer.

BTW, JavaScript (or ECMAScript) supports closures and lexical scoping, so
things you learn from Scheme would apply directly there.  Python also
supports both concepts.  Even the Perl documentation suggests using 'my'
(lexical scoping) instead of 'local' (dynamic scoping).

Dave


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

Reply via email to