[plt-scheme] Okay, you've got me thinking (was: Quicksort in Scheme)

From: Greg Woodhouse (gregory.woodhouse at sbcglobal.net)
Date: Wed Jan 4 16:25:55 EST 2006

I suppose continuations provide a "way out" (albeit a heavy handed one)
for destructive operations like set!

> (define strange
  (lambda (a b)
    (+ a
        (lambda (k)
          (set! a 0)
          (k b))))))
> (strange 4 5)

To be honest, the presence of operators like set! and set-car! in
Scheme has bothered me from the start (but I've tried to leave that
kind of debate to the Haskell list!) Now, maybe I'm on the wrong track
here, but I've been wondering wehat kind of data structures and
operations are "safe" from a functional perspective, and for that
matter, what safety is. Continuation is Scheme, seem like a kind of
sledge hammer, allowing you to undo essentially anything. So maybe the
above example isn't all that interesting. But be that as it may,
operations like set! seem to mess up the Church-Rosser theorem (i.e.,
make the order of reductions significant when we would like it not to
be). Is it possible to restore sanity in the face of operations with
side effects without explicit continuations? Does that even make sense?

Gregory Woodhouse  <gregory.woodhouse at sbcglobal.net>
"If you give someone Fortran, he has Fortran.
If you give someone Lisp, he has any language he pleases."
--Guy L. Steele, Jr. 

Posted on the users mailing list.