Subject: Re: call/cc
From: rpw3@rpw3.org (Rob Warnock)
Date: Thu, 06 Apr 2006 06:10:50 -0500
Newsgroups: comp.lang.lisp
Message-ID: <jKSdnYgVitGnaqnZRVn-sw@speakeasy.net>
Philippe Lorin  <palpalpalpal@gmail.com> wrote:
+---------------
| Pascal Costanza wrote:
| > What do you actually want to express?
| 
| It's a kind of cooperative multitasking.
| I need three things: CSTART, CSTEP and YIELD.
+---------------

CMUCL's "multiprocessing" (green threads, really) can easily do this
[given some trivial wrappers], as can SBCL and several other Common
Lisps with threads. In the case of CMUCL, I think this [untested]
does approximately what you asked for:

    (defmacro cstart (&body body)
      `(mp:make-process (lambda () (yield) ,@body)))

    (defun cstep (c)
      (mp-enable-process c))

    (defun yield ()
      (mp-disable-process mp:*current-process*))


-Rob

-----
Rob Warnock			<rpw3@rpw3.org>
627 26th Avenue			<URL:http://rpw3.org/>
San Mateo, CA 94403		(650)572-2607