[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: async 1.0
From: |
John Wiegley |
Subject: |
Re: async 1.0 |
Date: |
Sat, 23 Jun 2012 16:05:08 -0500 |
User-agent: |
Gnus/5.130006 (Ma Gnus v0.6) Emacs/24.1 (darwin) |
>>>>> Stephen J Turnbull <address@hidden> writes:
> XEmacs efs (or maybe it's dired -- not to be confused with any dired in
> Emacs IIRC, you need the XEmacs versions) has an implementation of call/cc.
> I don't know how close to "true" call/cc it is. For correct info, ask Mike
> Sperber <address@hidden>.
I'll have to check that out.
Eshell has a poor man's implementation of call/cc, called `eshell-do-eval'.
It throws `eshell-defer' as the equivalent of calling `call/cc', returning an
object you can `eval' later to resume execution.
The way it works is by taking the form you want to `eval' and transforming it
as it evaluates, performing substitutions so that (let ((a (+ 10 20))) ...)
becomes (let ((a 30)) ...), etc., on down to where you throw `eshell-defer'
(and of course removing the throw). The next time you evaluate, no additional
evaluations are done until you reach the point where you deferred.
The downsides are: (a) it's slow to walk and eval in Lisp, (b) it doesn't work
with byte-compiled forms, and (c) it's limited to a subset of the Emacs Lisp
language, since each single special form needs to be treated specially, and I
only implemented transforms for the ones that Eshell actually used. Oh, and
(a) it doesn't peer past function call boundaries.
That said, it could be extended to fully support Emacs Lisp; it would simply
require that nothing be byte-compiled. Unless bytecode stream instrumentation
was added to the mix...
On the other hand, how hard would it be to make Emacs stackless and provide a
native call/cc that works not only with byte-compiled code, but with
interposing native function calls? For example:
(let* ((a (+ 10 20))
(c '(1 2 3)))
(d (mapcar #'(lambda (b) (+ b a) (call/cc)) c)))
I cannot think of any way to fake continuations here, other than having
intimate of every native function, and transforming the `let' into this:
(let* ((a 30)
(b '(2 3))
(d (cons 1 (mapcar #'(lambda (b) (+ b a)) c))))
The problem gets pretty hairy fairly quickly.
John
- Re: async 1.0, (continued)
- ELPA and core services, John Wiegley, 2012/06/24
- Re: ELPA and core services, Lennart Borgman, 2012/06/24
- Re: ELPA and core services, Stefan Monnier, 2012/06/24
- ELPA and core services, Stephen J. Turnbull, 2012/06/25
- Re: ELPA and core services, Achim Gratz, 2012/06/25
- stdlib for Emacs? [was: async 1.0], Stephen J. Turnbull, 2012/06/25
- Re: async 1.0, Stephen J. Turnbull, 2012/06/23
- Re: async 1.0,
John Wiegley <=
Re: async 1.0, Richard Stallman, 2012/06/22