From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Jim Porter Newsgroups: gmane.emacs.devel Subject: Re: continuation passing in Emacs vs. JUST-THIS-ONE Date: Thu, 16 Mar 2023 15:14:52 -0700 Message-ID: <26126ff4-6e9c-0d45-d92c-95d3280a45e9@gmail.com> References: <627090382.312345.1678539189382@office.mailbox.org> <87ttyknzuq.fsf@miha-pc> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="25824"; mail-complaints-to="usenet@ciao.gmane.io" To: miha@kamnitnik.top, Thomas Koch , "emacs-devel@gnu.org" Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Thu Mar 16 23:15:44 2023 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 1pcvsu-0006Xw-14 for ged-emacs-devel@m.gmane-mx.org; Thu, 16 Mar 2023 23:15:44 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pcvsC-0001dD-3P; Thu, 16 Mar 2023 18:15:00 -0400 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 1pcvs9-0001ci-8L for emacs-devel@gnu.org; Thu, 16 Mar 2023 18:14:57 -0400 Original-Received: from mail-pg1-x531.google.com ([2607:f8b0:4864:20::531]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pcvs7-0001Lu-Jm for emacs-devel@gnu.org; Thu, 16 Mar 2023 18:14:57 -0400 Original-Received: by mail-pg1-x531.google.com with SMTP id k15so1065391pgt.10 for ; Thu, 16 Mar 2023 15:14:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1679004893; h=content-transfer-encoding:in-reply-to:from:references:to :content-language:subject:mime-version:date:message-id:from:to:cc :subject:date:message-id:reply-to; bh=VK8I36bC5WBWJ1ZBvAOuVbtIdhGsD2GzfNziWMEYbhA=; b=M5vi5rJBw73WIyA3bATQrXvKwPTTalwDn3xzhW+g+PC2bU9Wute9cGxSEhIj/JG9Se O9U0glg1K1C8+PSRX0NZuP0Pbi7htir1PqUZcBDfGX9mFcSQZFHn1TjsOVQmgp+2H3/U W2E63kbyYGnP5zIji+UltAOMJylXevJmxr2dTZ/gbuj4gaAYWhBOstxdYz3lFh1gebDk Q7sujoTLWIr2HfBcRZp1DkindglHA5KythZgRnRDSkPXjenm6fk3S89LaWem+kVMDP1w zFts2oTy9Bgx12H+FENCHlVlO0T4XEF813B+0cspMh8QSfXRRqgofjI/qC/5+EVV3eUJ e5Pg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1679004893; h=content-transfer-encoding:in-reply-to:from:references:to :content-language:subject:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=VK8I36bC5WBWJ1ZBvAOuVbtIdhGsD2GzfNziWMEYbhA=; b=ws+OlqlL7jOa++oYu2S5s2uDChedaJRelEy70gluE0sxuCKLpRRrtmkv7Za4KBc80+ un+Mvt3DMIW9bk7bdONjaq/7R6V0k9zKVQTT8Ol+Hm2tDUnZVUaWZaxmr1pvBcgI4i/v H5XIUDtjwKnebYw3qN6N3GJybDpWQhcEjx9e9e/dlTHCzi8vOigB6CIfNWlx0xI1tFqi bfba3SCwJPYJMdbcErnDBGhBNdo5XHDKnUBqXKl7v4X/kHNGjNTGjxdt93LaVMtE9iPG XwYyCBjgJTr2OASmEdt48v79XvzoJJDpFIteyiX+w7tIpRH4GSeopM7g1eslQKD/Km9H mOxQ== X-Gm-Message-State: AO0yUKUgzajPjUmThl8bn12RubOstCNe8NlZjYWYl3SXnzfruKuVtRXh C7lzTpVSkXqMDUY/WtjcUL+u/eUn/ZH6Rw== X-Google-Smtp-Source: AK7set8o1nzADF5i5f7hqqXx1g68UzwFNg2d2Eh7tuY/1YW4Pt14sHYN+UUP8sw0Ns1mUVaEwd/hUA== X-Received: by 2002:aa7:96b9:0:b0:625:ebc3:b26c with SMTP id g25-20020aa796b9000000b00625ebc3b26cmr3198214pfk.22.1679004893501; Thu, 16 Mar 2023 15:14:53 -0700 (PDT) Original-Received: from [192.168.1.2] (cpe-76-168-148-233.socal.res.rr.com. [76.168.148.233]) by smtp.googlemail.com with ESMTPSA id g5-20020a655805000000b005039c35225bsm117490pgr.94.2023.03.16.15.14.52 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 16 Mar 2023 15:14:53 -0700 (PDT) Content-Language: en-US In-Reply-To: <87ttyknzuq.fsf@miha-pc> Received-SPF: pass client-ip=2607:f8b0:4864:20::531; envelope-from=jporterbugs@gmail.com; helo=mail-pg1-x531.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_PDS_OTHER_BAD_TLD=0.01 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:304533 Archived-At: 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.