> A huge amount of the actively maintained state in Emacs is stored in
> global variables (often buffer-local of course, but still "global"
> as far as threads are concerned).
Thank you for the clarification.
I'm thinking of ways to avoid the stack penalties the other proposals
involve. Could we allow only secondary threads with thread-local
variables and forked copies of globals? Then, to modify the main
thread's version of a global variable a special protocol must be
followed (through the VM). Threads wouldn't be able to access
existing buffers and buffer-local variables without going through the
VM protocol, either (but they can create their own buffers, which will
be isolated within the thread). The ideal thread would be a pure
function (if I remember my definitions right, a pure function f(x)
depends only on x).
This will make threads more of a utility than a true built-in, and
threaded code would be written especially for that purpose. Existing
code would continue to run without changes - this will save us
rewriting a huge amount of code.
Is this feasible? Would this kind of limited threading be useful?