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: Sat, 11 Mar 2023 17:45:15 -0800 Message-ID: References: <627090382.312345.1678539189382@office.mailbox.org> 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="17974"; mail-complaints-to="usenet@ciao.gmane.io" To: Thomas Koch , "emacs-devel@gnu.org" Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Sun Mar 12 02:46:50 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 1pbAnS-0004Xt-8B for ged-emacs-devel@m.gmane-mx.org; Sun, 12 Mar 2023 02:46:50 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pbAmo-0005S7-1y; Sat, 11 Mar 2023 20:46:10 -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 1pbAmm-0005RO-3F for emacs-devel@gnu.org; Sat, 11 Mar 2023 20:46:08 -0500 Original-Received: from mail-pl1-x62b.google.com ([2607:f8b0:4864:20::62b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pbAmi-0007Jf-R9 for emacs-devel@gnu.org; Sat, 11 Mar 2023 20:46:07 -0500 Original-Received: by mail-pl1-x62b.google.com with SMTP id k2so1579557pll.8 for ; Sat, 11 Mar 2023 17:45:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1678585516; 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=D/43poWCI4MEOwZD45woskn5aHi+TJkOBmm/T+kFWFc=; b=gX+j0XP6+5Er1w3TiuQxatpCdPlcQAOZOux8iD+mOMoMePLu1FpFrkM4vVGmjzU7Yq 73ASEg7KdNiOV+X3xbwPVqX/10VTAAzDjdLdoWI6PQ1gRbUr+WpqnMh9O9dDrm2lDWHe gD0C/D9FkTucVgXqe2PWvFb6HSPe1bTlkArtrTvlJ9FlytSh2pFokI1Y+P4xo5DLxyTI hkcu43Kk9FdmOjzesFesC7sGORMX6evuihb6/5P4NkE3pH7QMDunA3jya3hiFiqEjoE6 NOe9V+K1Ap1ltOj7vWs5CEV/fjIdI0FBe2Abn2VivR1J4nCWgCdxlPJ1gj1fferDWN1B 0hEg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678585516; 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=D/43poWCI4MEOwZD45woskn5aHi+TJkOBmm/T+kFWFc=; b=xc6y8ibZ5esP42QQjU4B7IGzD9Ld3wPT5NnVxGIkHDmAgSwPFpngQ1iXrzsNuZck0G ne3CaaFN7al6tmP6bVWafngw9leSaDPa3SxsI0zNo6oBdpkV/zu6TNKTnXuO40egBwCb SUkkEmsAXqhB2K5vRuqfdcDrMy5fW3DWPJDHxMPoaSb3TS19DDLxCBMR4ATawbFGjOkH aL3HC+6HXats/veUkChXx23L2G4+3qVm654EBP+2L2pJWA8XqXHbRvbt900SmMZPOk+m ZE1xoYxR1Vd5VKTBd4qj/VW4gtxDkk3KnYxqZptCMVRAs/BWvVay5Y9KIgm9uGtp4f1E MzRw== X-Gm-Message-State: AO0yUKVvJs8x14JyxXSqW1OEkT1MsfjWaRnRoAEhgspPDGY/VEpY7rZC wposWdTKXOb1A7cGCM6LCdQ= X-Google-Smtp-Source: AK7set9NUib0qftI4mjaC8dxKKLxnAbdlcj4ec8gAbjfvDkJM/+3wFcqPQj3kbRIdfRooQOgMSwrTQ== X-Received: by 2002:a17:90b:4d8e:b0:231:10da:59fc with SMTP id oj14-20020a17090b4d8e00b0023110da59fcmr30426420pjb.2.1678585516405; Sat, 11 Mar 2023 17:45:16 -0800 (PST) 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 lp18-20020a17090b4a9200b001fde655225fsm3375912pjb.2.2023.03.11.17.45.15 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sat, 11 Mar 2023 17:45:15 -0800 (PST) Content-Language: en-US In-Reply-To: <627090382.312345.1678539189382@office.mailbox.org> Received-SPF: pass client-ip=2607:f8b0:4864:20::62b; envelope-from=jporterbugs@gmail.com; helo=mail-pl1-x62b.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 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:304344 Archived-At: On 3/11/2023 4:53 AM, Thomas Koch wrote: > TL;DR: (Why) is there no standard way for continuation passing style[1] ("event driven") programming in Emacs? There is (sort of): generator.el. There's also 'eshell-do-eval', but that's not as useful for general purposes, and I hope to replace it with either generator.el or real threads at some point in the future. It would probably be reasonable to add a more asynchronous-oriented way of working with generator.el's CPS machinery, but I think the bigger problem is just the time to fix existing code that's not doing the right thing. Even without an easy-to-use asynchronous programming interface, you could probably get pretty far in terms of real-world improvements with using timers. I imagine timers would be a lot clumsier than a "proper" async API, but they'd likely work well enough for a first pass. In any case, working on this would likely be a big help for Emacs. One of the more-common things I see people wish for in Emacs is "threading". I think this is probably a mistaken wish (Emacs generally doesn't use enough CPU to saturate a core), but what they really want is for fewer operations that block for a long time. If it were easier to divide up long-running tasks into small chunks, that would go a long way towards solving these sorts of issues. (In theory, you could even get real multithreading this way, if you could divide up your task in a way that Emacs could be sure some chunk can be offloaded onto another thread.)