On Fri, Dec 28, 2007 at 04:16:36PM -0800, Tracy R Reed wrote:
SJS wrote:
It'll be interesting to see how well it works. My disbelief is probably
founded on encountering scheme as my ... ninth(?) programming language.
I was pretty well schooled in the procedural languages by then. . .
That seems to be the big problem with learning a functional language after
spending years with procedural. You have to be exceptionally open-minded to
make the switch. That doesn't mean it isn't worth making. Reasonable
people can disagree on what language is the best for doing any particular
task but I don't think reasonable people can disagree on whether
scheme/lisp are worth learning. They are.
Scheme/lisp are only part of the way toward functional programming
languages. Most programs still rely heavily on mutable data.
If you really want to learn functional programming, learn Haskell. It
really takes some mind bending, but I found it to be fun, even if not
really useful. It also uses lazy evaluation, where expressions aren't
evaluated until the result is needed. It allows you to easily express
infinite data structures. That way the code that traverses the structure
(which will be a finite part of it) can be kept separate from the code that
generates the structure.
Unix (or *nix) has a simplistic version of this with pipes:
yes | bar
'yes' generates data, as demanded by bar. When 'bar' exists, 'yes' stops
running.
I believe that does modify the global symbol table but that isn't the only
way to do it. Most schemers seem to use closures to eliminate the use of
globals. I dislike globals also and hope to learn more about this technique
for eliminating their use.
There's nothing wrong, at all, with a global that doesn't change. The
problems come with globals that can change value. Things define'd will
only be set once, so there is nothing wrong with using them. This isn't
any different than defining a function or procedure in another language.
For mutable state, it is much better to keep that in closures.
Again, "pure" functional programming doesn't have any mutable state.
Dave
--
[email protected]
http://www.kernel-panic.org/cgi-bin/mailman/listinfo/kplug-list