emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: continuation passing in Emacs vs. JUST-THIS-ONE


From: Jim Porter
Subject: Re: continuation passing in Emacs vs. JUST-THIS-ONE
Date: Mon, 13 Mar 2023 23:28:12 -0700

On 3/13/2023 8:58 PM, Richard Stallman wrote:
[[[ To any NSA and FBI agents reading my email: please consider    ]]]
[[[ whether defending the US Constitution against all enemies,     ]]]
[[[ foreign or domestic, requires you to follow Snowden's example. ]]]

   > TL;DR: (Why) is there no standard way for continuation passing
   > style[1] ("event driven") programming in Emacs?

I implemented Emacs Lisp using simple, natural C data structures
including the C call stack.  This does not lend itself to implementing
continuations.

To change that would be enormous trouble, and i expect it would cause
a big slowdown too.  In my opinion, continuation-passing style is not
worth that downside.

There's already some support in Emacs for coroutines: generator.el provides, well... generators, which should allow for most (all?) of what you can normally do with coroutines, albeit with syntax that might not be as fluent as we might like. This is implemented entirely in Lisp, so I wouldn't be surprised if the performance suffers, but for certain kinds of tasks where Emacs isn't CPU-bound, even that could be a significant improvement for overall responsiveness.

For this thread in particular, I believe it's inspired by some issues with Tramp, where (if I understand correctly), process filters from relatively-long network operations are causing hangs (and also the dreaded "forbidden reentrant call to Tramp" error). In these cases, I think it's at least reasonably likely that the operations in question are network/IO-bound, so slicing them up into continuations might be good enough, even if those continuations have a performance penalty in terms of CPU use.

Of course, without at least a simple proof of concept, it's hard to say what the pros and cons look like. I'm hoping to test something like this out in Eshell by using/adapting generator.el, since Eshell already effectively contains its own CPS transformer called 'eshell-do-eval'.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]