|
From: | Jim Porter |
Subject: | Re: continuation passing in Emacs vs. JUST-THIS-ONE |
Date: | Sat, 11 Mar 2023 17:45:15 -0800 |
On 3/11/2023 4:53 AM, Thomas Koch wrote:
TL;DR: (Why) is there no standard way for continuation passing style[1] ("event driven") programming in Emacs?
There is (sort of): generator.el. There's also 'eshell-do-eval', but that's not as useful for general purposes, and I hope to replace it with either generator.el or real threads at some point in the future.
It would probably be reasonable to add a more asynchronous-oriented way of working with generator.el's CPS machinery, but I think the bigger problem is just the time to fix existing code that's not doing the right thing. Even without an easy-to-use asynchronous programming interface, you could probably get pretty far in terms of real-world improvements with using timers. I imagine timers would be a lot clumsier than a "proper" async API, but they'd likely work well enough for a first pass.
In any case, working on this would likely be a big help for Emacs. One of the more-common things I see people wish for in Emacs is "threading". I think this is probably a mistaken wish (Emacs generally doesn't use enough CPU to saturate a core), but what they really want is for fewer operations that block for a long time. If it were easier to divide up long-running tasks into small chunks, that would go a long way towards solving these sorts of issues.
(In theory, you could even get real multithreading this way, if you could divide up your task in a way that Emacs could be sure some chunk can be offloaded onto another thread.)
[Prev in Thread] | Current Thread | [Next in Thread] |