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: Thu, 16 Mar 2023 15:14:52 -0700

On 3/16/2023 2:35 PM, miha@kamnitnik.top wrote:
There's also the issue that using continuation passing (async-io)
doesn't auto-magically solve the re-entrancy issues.

Consider the following hypothetical command, written using JS-style
async/await operators:

(async-defun insert-some-parent-dirs ()
   (interactive)
   (insert (await (locate-dominating-file default-directory "go.mod")))
   (insert "\n")
   (insert (await (locate-dominating-file default-directory "go.work"))))

If the user executed such a command multiple times in quick succession,
the executions could happen in parallel and would trample over each
other.

For each use of "await", the programmer has to think about the
possibility of other code running "in-between". This style of
programming may be harder in Elisp which has a lot of global state in
form of buffer contents, markers and overlays.

Yeah, this isn't easy to fix on its own. The best I can think of (and this would take quite a bit of experimentation) would be some way of declaring async functions as non-reentrant for certain contexts. So your example would be non-reentrant for a given buffer. Some other functions might be non-reentrant globally, or for a particular argument to the function.

With a declaration like that, we could hopefully go a fair way towards solving the problem by serializing any async calls that are non-reentrant.

I hope to test out Stefan's futur.el (and maybe vanilla generator.el) as a new iterative evaluation backend for Eshell in the coming months; hopefully that will help produce some more concrete information about what the pitfalls are.



reply via email to

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