From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Konstantin Kharlamov Newsgroups: gmane.emacs.devel Subject: Re: continuation passing in Emacs vs. JUST-THIS-ONE Date: Tue, 18 Apr 2023 13:35:42 +0300 Message-ID: <819ba9e84aa843a60cf1113f0306ea62e94975df.camel@yandex.ru> References: <87leizif4r.fsf@logand.com> <874jpmfaw9.fsf@logand.com> <87v8i2dnm3.fsf@logand.com> <83jzyh8w7l.fsf@gnu.org> <87v8hup705.fsf@logand.com> <834jpe9bb0.fsf@gnu.org> Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="16782"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Evolution 3.46.4 Cc: monnier@iro.umontreal.ca, jporterbugs@gmail.com, karthikchikmagalur@gmail.com, emacs-devel@gnu.org To: Eli Zaretskii , Tomas Hlavaty Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Tue Apr 18 12:36:52 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 1poihf-00047l-Ja for ged-emacs-devel@m.gmane-mx.org; Tue, 18 Apr 2023 12:36:51 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1poigk-0001H9-CD; Tue, 18 Apr 2023 06:35:54 -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 1poigi-0001Gl-4b for emacs-devel@gnu.org; Tue, 18 Apr 2023 06:35:52 -0400 Original-Received: from forward500a.mail.yandex.net ([178.154.239.80]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1poigf-0005uU-Kd; Tue, 18 Apr 2023 06:35:51 -0400 Original-Received: from mail-nwsmtp-smtp-production-main-84.vla.yp-c.yandex.net (mail-nwsmtp-smtp-production-main-84.vla.yp-c.yandex.net [IPv6:2a02:6b8:c0f:26a7:0:640:a2d5:0]) by forward500a.mail.yandex.net (Yandex) with ESMTP id F41D65EC56; Tue, 18 Apr 2023 13:35:43 +0300 (MSK) Original-Received: by mail-nwsmtp-smtp-production-main-84.vla.yp-c.yandex.net (smtp/Yandex) with ESMTPSA id gZZdmCADXCg0-hYEhiNqc; Tue, 18 Apr 2023 13:35:43 +0300 X-Yandex-Fwd: 1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex.ru; s=mail; t=1681814143; bh=faJQUFvPwrwvAXUqMErV1rG1ptlexlAH0jeLT/6mVIA=; h=References:Date:In-Reply-To:Cc:To:From:Subject:Message-ID; b=MBrgN64o256NjIMfPkAJ+7JMwzWdkfR+RkEcO0i7j7K63RG2EPLzFb1Gto1u7xfZn h1TVMwcTACOOQjVUVZQfwumSzDbO9WSh3SQjCavb0xlYJUtgYuoZfqnzTSgBPmk/eD pvkWB5M5bmUk2HPUm8Gdc5xbqgsl7LvY9y2sgy+s= Authentication-Results: mail-nwsmtp-smtp-production-main-84.vla.yp-c.yandex.net; dkim=pass header.i=@yandex.ru In-Reply-To: <834jpe9bb0.fsf@gnu.org> Received-SPF: pass client-ip=178.154.239.80; envelope-from=hi-angel@yandex.ru; helo=forward500a.mail.yandex.net X-Spam_score_int: -10 X-Spam_score: -1.1 X-Spam_bar: - X-Spam_report: (-1.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, FREEMAIL_REPLY=1, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no 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:305403 Archived-At: On Tue, 2023-04-18 at 05:25 +0300, Eli Zaretskii wrote: > > From: Tomas Hlavaty > > Cc: monnier@iro.umontreal.ca, jporterbugs@gmail.com, > > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0karthikchikmagalur@gmai= l.com, emacs-devel@gnu.org > > Date: Mon, 17 Apr 2023 22:51:22 +0200 > > > > On Wed 12 Apr 2023 at 09:13, Eli Zaretskii wrote: > > > Async subprocesses are currently the only feature in Emacs that > > > provides an opportunity for writing asynchronous code. > > > > Do you not consider, for example, using implementations of async/await > > using promisses and CPS rewriting "writing asynchronous code"? > > > > Do you not consider, for example, doing the same using callbacks as > > "writing asynchronous code"? > > Not necessarily. > > > > > I do not know how useable threads in Emacs are at the moment, > > > > but they are already there and the examples I tried worked well. > > > > > > If you think Lisp threads in Emacs allow asynchronous processing, you > > > are mistaken: they don't.=C2=A0 Only one such thread can be running a= t any > > > given time. > > > > The examples I wrote worked fine with threads.=C2=A0 The examples did n= ot > > require parallelism.=C2=A0 I do not think that what you suggest disqual= ifies > > threads for "writing asynchronous code". > > > > It would be great to have better thread implementation, but that does > > not seem to have anything to do with "writing asynchronous code". > > > > Here is what I understand under synchronous code: > > > > =C2=A0=C2=A0 (plus 1 2) > > =C2=A0=C2=A0 returns 3 immediatelly > > > > Here is what I understand under asynchronous code: > > > > =C2=A0=C2=A0 (plus 1 2) > > =C2=A0=C2=A0 returns something immediately > > =C2=A0=C2=A0 and then some time later 3 appers in the *Message* buffer,= for > > =C2=A0=C2=A0 example > > > > How that is achieved is an implementation (possibly leaky) detail. > > In my book, asynchronous means parallel processing, not just delayed > results. The widely used definition is different though. A good summary is in this StackOverflow answer=C2=B9: > When you run something asynchronously it means it is non-blocking, you ex= ecute it > without waiting for it to complete and carry on with other things. Parall= elism > means to run multiple things at the same time, in parallel. Parallelism w= orks well > when you can separate tasks into independent pieces of work. If you want some Wikipedia links, they might sound a bit more confusing, bu= t here's what it says=C2=B2: > Asynchrony, in computer programming, refers to the occurrence of events i= ndependent > of the main program flow and ways to deal with such events. These may be = "outside" > events such as the arrival of signals, or actions instigated by a program= that take > place concurrently with program execution, without the program blocking t= o wait for > results. And then "concurrency" article says=C2=B3: > The concept of concurrent computing is frequently confused with the relat= ed but > distinct concept of parallel computing,[3][4] although both can be descri= bed as > "multiple processes executing during the same period of time". In paralle= l > computing, execution occurs at the same physical instant: for example, on= separate > processors of a multi-processor machine, with the goal of speeding up > computations=E2=80=94parallel computing is impossible on a (one-core) sin= gle processor, as > only one computation can occur at any instant (during any single clock cy= cle).[a] > By contrast, concurrent computing consists of process lifetimes overlappi= ng, but > execution need not happen at the same instant. 1: https://stackoverflow.com/a/6133756/2388257 2: https://en.wikipedia.org/wiki/Asynchrony_(computer_programming) 3: https://en.wikipedia.org/wiki/Concurrent_computing