From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.devel Subject: Re: [RFC] Adding threads to Eshell Date: Fri, 16 Dec 2022 09:05:11 -0500 Message-ID: References: <7f4e3357-2c6a-a0d2-cab5-fb641b52877a@gmail.com> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="23908"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Cc: emacs-devel@gnu.org To: Jim Porter Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Fri Dec 16 15:06:05 2022 Return-path: Envelope-to: ged-emacs-devel@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1p6BLg-0005zP-QE for ged-emacs-devel@m.gmane-mx.org; Fri, 16 Dec 2022 15:06:05 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1p6BL7-0001Aq-Sm; Fri, 16 Dec 2022 09:05:32 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1p6BL1-00018l-O5 for emacs-devel@gnu.org; Fri, 16 Dec 2022 09:05:23 -0500 Original-Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1p6BKx-0002sE-Uk for emacs-devel@gnu.org; Fri, 16 Dec 2022 09:05:23 -0500 Original-Received: from pmg2.iro.umontreal.ca (localhost.localdomain [127.0.0.1]) by pmg2.iro.umontreal.ca (Proxmox) with ESMTP id D35D4807E9; Fri, 16 Dec 2022 09:05:15 -0500 (EST) Original-Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1]) by pmg2.iro.umontreal.ca (Proxmox) with ESMTP id D644180536; Fri, 16 Dec 2022 09:05:13 -0500 (EST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca; s=mail; t=1671199513; bh=8G7VdMxNJrV1lkeBc7Su+FDo5CgEIEcJonRAqZ4giKA=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From; b=nfwJKurpcksEm0P1/iLQa9ZUI69OzygWXh56rc8PfNGpRH2wfVOKjnxZ/hJojNY49 zeCYPmfiHiII/A/Yofofq/BdBPosxb89N4eoCD/+UZmSicVjLDk5SvyKefmtIiYVBu QM1quoAtlBQB2lT6ZOQ9rP1rx3hk1E2FiMomdIui+RfVCSZOGqEP7qtj5h6qotTDwb +pFXTza+NxPBK9O23HwCjo9hYt13I7HRJS8Sabfy4E6LlV4jhdXCOHnjnmkutO+9+P AkYrd91eEonljdBHoG5wloTi2k3U82WSsYyEVrncz6VY2YfV6wYFN8RVxKj4zYmcRT aojEAhQmPk8yA== Original-Received: from pastel (unknown [45.72.193.52]) by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id 9A0BD120679; Fri, 16 Dec 2022 09:05:13 -0500 (EST) In-Reply-To: <7f4e3357-2c6a-a0d2-cab5-fb641b52877a@gmail.com> (Jim Porter's message of "Thu, 15 Dec 2022 18:37:09 -0800") Received-SPF: pass client-ip=132.204.25.50; envelope-from=monnier@iro.umontreal.ca; helo=mailscanner.iro.umontreal.ca X-Spam_score_int: -42 X-Spam_score: -4.3 X-Spam_bar: ---- X-Spam_report: (-4.3 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.devel:301485 Archived-At: > lisp/eshell/esh-cmd.el). This requires a lot of code to handle various Lisp > special forms, and the allowed forms are fairly limited. It also has a few > bugs, likely due in part to being written before lexical binding. I remember discussing this with John the one time we got to meet face to face and him telling me that he didn't know the concept of CPS-conversion back then :-) > 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. > 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). > Is it possible to tell a thread that I want to inherit the bindings > from wherever I called 'make-thread'? For statically scoped vars, this should already be the case because the (lambda ....) you pass to `make-thread` will close over the surrounding static scopes. 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 I've had some fun writing an `lml.el` compatibility package which includes support for that. The corresponding part of the code is: (oclosure-define (lml-closure (:predicate lml-closurep)) bindings function) (defun lml--closure (bindings function) (oclosure-lambda (lml-closure (bindings bindings) (function function)) (&rest args) (cl-progv (mapcar #'car bindings) (mapcar #'cdr bindings) (apply function args)))) (defun lml-closure (varlist function) "Create a closure over the dynamic variables in VARLIST." (lml--closure (mapcar (lambda (v) (cons v (symbol-value v))) varlist) function)) -- Stefan