all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Jim Porter <jporterbugs@gmail.com>
To: Stefan Monnier <monnier@iro.umontreal.ca>
Cc: emacs-devel@gnu.org
Subject: Re: [RFC] Adding threads to Eshell
Date: Fri, 16 Dec 2022 12:11:05 -0800	[thread overview]
Message-ID: <fe86032d-773d-29f2-350a-d6ddf1e72cc7@gmail.com> (raw)
In-Reply-To: <jwvtu1v4h5x.fsf-monnier+emacs@gnu.org>

On 12/16/2022 6:05 AM, Stefan Monnier wrote:
>> However, before I go too far, I wanted to check with other, more
>> knowledgeable people: are Emacs threads available on all platforms?
> 
> I'll let others answer this part.  IIUC the answer is not "yes", but
> like you I hope the cases where they're not supported can be simply
> swept under the rug.

I'm not sure it's worth the added complexity (yet?), but maybe it would 
be useful to have some generic way of executing code asynchronously 
(probably using CPS-transformations). Then you could pass this code to a 
thread if those are available, or if not, just run in the main thread 
when Emacs is idle.

>> A second issue I noticed is that Emacs threads have their own,
>> completely separate set of lexical bindings.
> 
> Do you really mean *lexical* bindings?
> If yes, then I don't understand what you mean (I don't understand how
> they could be non-completely separate).

I suppose I mean *local* bindings, really. The manual says, "The new 
thread is created with no local variable bindings in effect." That's 
something that I think would be nice to change in this case, so that a 
user could do something like:

   (let ((some-defvar t))
     (eshell-command "echo $some-defvar"))

Internally, 'eshell-command' would convert "echo $some-defvar" to some 
Lisp form, then call 'make-thread' and eval that form in the thread.

> For dynamically scoped vars, you'd have to do it more explicitly.
> Lisp Machine Lisp had an operation they called `closure` for that
> purpose (they didn't have static scoping at all).
> See https://hanshuebner.github.io/lmman/fd-clo.xml

That sounds like what I want. Thanks for the code snippet.

The only bit I'm still unsure about is if there's a good (and 
performant) way to ask, "What are all the local bindings of dynamic 
variables?" Then, I could use that to feed those bindings to the thread 
and this would work. (I'm still not sure whether this is the right thing 
to do in the first place, but I want to see what it's like. It would 
also make more of the regression tests pass, which would make it easier 
to keep developing this.)



  reply	other threads:[~2022-12-16 20:11 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-12-16  2:37 [RFC] Adding threads to Eshell Jim Porter
2022-12-16 14:05 ` Stefan Monnier
2022-12-16 20:11   ` Jim Porter [this message]
2022-12-17  3:40     ` Stefan Monnier
2022-12-17  5:19       ` Jim Porter
2022-12-16 19:51 ` Eli Zaretskii
2022-12-16 20:25   ` Jim Porter

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=fe86032d-773d-29f2-350a-d6ddf1e72cc7@gmail.com \
    --to=jporterbugs@gmail.com \
    --cc=emacs-devel@gnu.org \
    --cc=monnier@iro.umontreal.ca \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.