emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: continuation passing in Emacs vs. JUST-THIS-ONE


From: Konstantin Kharlamov
Subject: Re: continuation passing in Emacs vs. JUST-THIS-ONE
Date: Tue, 18 Apr 2023 13:35:42 +0300
User-agent: Evolution 3.46.4

On Tue, 2023-04-18 at 05:25 +0300, Eli Zaretskii wrote:
> > From: Tomas Hlavaty <tom@logand.com>
> > Cc: monnier@iro.umontreal.ca, jporterbugs@gmail.com,
> >         karthikchikmagalur@gmail.com, emacs-devel@gnu.org
> > Date: Mon, 17 Apr 2023 22:51:22 +0200
> >
> > On Wed 12 Apr 2023 at 09:13, Eli Zaretskii <eliz@gnu.org> 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.  Only one such thread can be running at any
> > > given time.
> >
> > The examples I wrote worked fine with threads.  The examples did not
> > require parallelism.  I do not think that what you suggest disqualifies
> > 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:
> >
> >    (plus 1 2)
> >    returns 3 immediatelly
> >
> > Here is what I understand under asynchronous code:
> >
> >    (plus 1 2)
> >    returns something immediately
> >    and then some time later 3 appers in the *Message* buffer, for
> >    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¹:

> When you run something asynchronously it means it is non-blocking, you 
> execute it
> without waiting for it to complete and carry on with other things. Parallelism
> means to run multiple things at the same time, in parallel. Parallelism works 
> well
> when you can separate tasks into independent pieces of work.

If you want some Wikipedia links, they might sound a bit more confusing, but 
here's
what it says²:

> Asynchrony, in computer programming, refers to the occurrence of events 
> independent
> 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 to 
> wait for
> results.

And then "concurrency" article says³:

> The concept of concurrent computing is frequently confused with the related 
> but
> distinct concept of parallel computing,[3][4] although both can be described 
> as
> "multiple processes executing during the same period of time". In parallel
> 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—parallel computing is impossible on a (one-core) single 
> processor, as
> only one computation can occur at any instant (during any single clock 
> cycle).[a]
> By contrast, concurrent computing consists of process lifetimes overlapping, 
> 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




reply via email to

[Prev in Thread] Current Thread [Next in Thread]