Dreams.

Ben Caradoc-Davies bmcd at es.co.nz
Sun Jul 11 00:46:49 EDT 1999


Hmmm. I'm not sure what your background is, Scott, but you may not be aware of
some previous work --- the term you may be looking for is "continuation". The
use of continuations is the explicit aim of a number paradigms, particularly in
the functional language world and "artificial intelligence". Continuations can
be used to implement "backtracking", where, for example, a program explores
one branch of execution, reaches a dead end, and restores it's previous state
by falling back on a saved continuation.

A continuation can be described as a function representing the work yet to be
done.

Have you read "The Structure and Interpretation of Computer Programs" by
Abelson and Sussman? A real eye-opener, especially for someone with a physics
Fortran/C/Matlab background. Changed my world-view. I have heard this book
often recommended as one of the best. It is (used to be?) required reading for
MIT comp. sci. and e.e. undergraduates. The second edition came out recently.
The book uses the Scheme language
  http://www.swiss.ai.mit.edu/scheme-home.html

Check out Ken Dickey's intro to scheme
  ftp://ftp.cs.indiana.edu/pub/scheme-repository/doc/pubs/intro.txt
which has some examples of how to rewrite a function in a continuation passing
style.

Also look in on comp.lang.scheme, comp.lang.lisp and comp.lang.functional. Read
the functional programming faq.

One of the basic ideas behind functional (a.k.a. applicative) programming is
avoiding the use of assignment to get around the problems of saving state
which, as you have correctly deduced, causes a lot of problems. There has been
a large amount of work done on these problems since the seventies. Look for
resources on "closures," "continuations," "functional programming," and
"backtracking."

ObPython:
The funny thing is, coming from Scheme, I found that Guido had put the best of
Scheme into Python. Python's major advantages are clear syntax and semantics, a
well-defined foreign function interface, and (consequently) a large library and
numerous extensions.

"Alms for a poor *ex*-schemer!"
"Did you say *ex*-schemer?"
"Yes. One minute I was a schemer with a livelihood. Next, along comes Guido.
  *Cures* me! No so much as a by-your-leave!"

-- 
Ben Caradoc-Davies <bmcd at es.co.nz>




More information about the Python-list mailing list