unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Dmitry Gutov <dgutov@yandex.ru>
To: Daniel Mendler <mail@daniel-mendler.de>, emacs-devel@gnu.org
Subject: Re: Improvement proposals for `completing-read'
Date: Sun, 11 Apr 2021 03:51:43 +0300	[thread overview]
Message-ID: <759ed5ae-8d58-e73b-244b-08bd86aafb2d@yandex.ru> (raw)
In-Reply-To: <e5645803-81a6-588a-2c8e-e2fee00d40bf@daniel-mendler.de>

On 10.04.2021 12:18, Daniel Mendler wrote:
> On 4/10/21 4:21 AM, Dmitry Gutov wrote:
>>> These `consult--async-*` functions can be chained together to produce 
>>> an async pipeline. The goal here was to have reusable functions which 
>>> I can glue together to create different async backends. See for 
>>> example the pipeline for asynchronous commands: 
>>> https://github.com/minad/consult/blob/3121b34e207222b2db6ac96a655d68c0edf1a449/consult.el#L1505-L1513. 
>>
>>
>> I also like that idea.
>>
>> How are the backtraces in case of error? Whether they can be made 
>> readable enough, was one of the sticking points in the (quite heated) 
>> discussion of bug#41531.
> 
> Backtraces are rather opaque. But having such issues on the language 
> level should not be a road block. I think the proper fix would be to 
> improve the debugging infrastructure slightly.
> 
> Instead of printing bytecodes - make this more accessible. Either show 
> some disassembled string or show location information, which should be 
> attached to the lambdas. Elisp retains all the information due to its 
> dynamic nature. So all the information is still present, we can print 
> all objects in a nice way.

If you just (load ...) the package, there will be no bytecode in the 
output. I was more concerned about simply how it reads (whether it's 
easy enough to diagnose a problem by reading the backtrace). Or at least 
whether it's not considerably worse than the alternatives.

Regarding navigation, though, precise symbol locations are an old Emacs 
problem. IIRC Alan posted about making some progress on it in the recent 
months, and lambdas could indeed similarly be annotated with that solution.

> Then there were a few other issue with lambdas, I think the interpreter 
> captures too much in the closures which can leads to large closures, 
> which is bad for debugability. The bytecode compiler in contrast seems 
> to perform an analysis. Is this right - please correct me if I am wrong? 
> I wonder why there is even the actual interpreter left - why is it not 
> possible to pass everything through bytecode? I guess this is a legacy 
> issue and also a bootstrapping issue since the bytecode compiler is 
> written in elisp itself.

Speed, probably (all the JS VMs include an interpreter stage, IIRC)?

And if we always worked with byte code directly, stuff like edebug, 
backtrace printer, would need to be repurposed.

There are others here better qualified to answer, anyway.

> Furthermore I had another issue with lambdas - if you create large 
> closures, which I am doing with Consult async, which capture the whole 
> candidates set, then you end up with memory problems if you register 
> these closures as hooks. The problem is that `add-hook/remove-hook` 
> compares using `equal` and this uses hash tables internally, which can 
> get very expensive. See bug#46326, bug#46407 and bug#46414.

Perhaps that's another reason not to use hook for this, and instead to 
attach frontend updater callbacks to the "future" values directly? With 
lexically scoped callbacks, for example.

>> I would probably say that a UI should itself know better when to 
>> refresh or not, but I'm guessing you have good counter-examples.
> 
> One could update the UI using some timer if an async source is used 
> (polling). However since I am setting this on top of the 
> `completing-read' infrastructure I felt it to be better to do it the 
> other way round, since the table is only queried when the user enters 
> new input. I guess for fast sources polling will be as good, but for 
> slow sources, notifying the UI is better.

Perhaps we're just talking about the same thing, differently.

What I meant, the source should invoke the callback when it gets new 
data, and the callback should store the result somewhere, and it can 
notify the UI about the possibility of refreshing (the frontend 
implements the callback, so it knows whether and how to do it). But 
whether to refresh right away, or wait, debounce, or simply discard the 
output, should be the frontend's choice.

>>>> No hurry at all. Sometimes, though, a big feature like that can 
>>>> inform the whole design from the outset.
>>>
>>> Yes, sure. When planning to do a big overhaul you are certainly 
>>> right. But currently I am more focused on fixing a few smaller pain 
>>> points with the API, like retaining text properties and so on.
>>
>> Sounds good. I just wanted to add some context for completeness, in 
>> case the work turns into the direction of the "next completing-read".
> 
> Yes, it seems the discussion already went a bit in that direction. I 
> agree that it is good to keep all these points in the head if one 
> designs a new `completing-read'. However from my work on Consult I am 
> actually not that unhappy with `completing-read' as is. With the handful 
> of small proposals I made in my original mail the state will be improved 
> where I had issues. If you look at my `consult--read` wrapper, it has to 
> do some special enhancements (preview, narrowing, async, ...), but I 
> think one can work reasonably well with the `completing-read' API. For 
> now I prefer to work with what exists than throwing everything out. At 
> least the Consult/Embark package show that one can implement more 
> advanced completion features based on top of the existing 
> infrastructure, with only a small amount of advices/hacks.

I've read it briefly, thanks.

Sounds like you have what is needed to propose an "async" extension to 
the standard completion tables API?

;-)

(No pressure.)



  reply	other threads:[~2021-04-11  0:51 UTC|newest]

Thread overview: 89+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-04-07 11:16 Improvement proposals for `completing-read' Daniel Mendler
2021-04-07 17:11 ` Stefan Monnier
2021-04-07 17:20   ` Stefan Monnier
2021-04-07 19:46     ` Daniel Mendler
2021-04-07 21:26       ` Stefan Monnier
2021-04-08  9:01         ` Daniel Mendler
2021-04-08 14:44           ` Stefan Monnier
2021-04-08 15:26             ` Stefan Kangas
2021-04-08 15:47               ` Daniel Mendler
2021-04-08 17:31               ` Stefan Monnier
2021-04-08 15:37             ` Daniel Mendler
2021-04-08 17:22               ` [External] : " Drew Adams
2021-04-08 18:22                 ` Dmitry Gutov
2021-04-08 18:48                   ` Drew Adams
2021-04-08 19:03                     ` Dmitry Gutov
2021-04-08 19:32                       ` Drew Adams
2021-04-08 17:30               ` Stefan Monnier
2021-04-08 17:57                 ` Daniel Mendler
2021-04-08 18:13                   ` Stefan Monnier
2021-04-08 19:15                     ` Daniel Mendler
2021-04-08 19:20               ` Dmitry Gutov
2021-04-08 19:46                 ` [External] : " Drew Adams
2021-04-08 20:12                   ` Dmitry Gutov
2021-04-08 21:12                     ` Drew Adams
2021-04-08 22:37                     ` Stefan Kangas
2021-04-09  0:03                       ` Dmitry Gutov
2021-04-09  2:09                         ` Using more and/or better icons in Emacs Stefan Kangas
2021-04-09  3:09                           ` Lars Ingebrigtsen
2021-04-09  3:35                           ` chad
2021-04-09 12:06                             ` Stefan Kangas
2021-04-09  7:41                           ` Yuri Khan
2021-04-09  9:59                             ` tomas
2021-04-09 11:15                               ` Dmitry Gutov
2021-04-09 11:19                           ` Dmitry Gutov
2021-04-09 12:22                             ` Stefan Kangas
2021-04-09 12:29                               ` Dmitry Gutov
2021-04-09 17:46                                 ` Stefan Kangas
2021-04-09 18:45                                   ` Eli Zaretskii
2021-04-09 19:30                                   ` Alan Third
2021-04-09 19:40                                     ` Alan Third
2021-04-09 22:38                                       ` Dmitry Gutov
2021-04-10  0:56                                       ` Stefan Kangas
2021-04-10  1:43                                         ` Stefan Kangas
2021-04-10  9:12                                           ` Alan Third
2021-04-10 10:56                                             ` Stefan Kangas
2021-04-10 13:48                                               ` Alan Third
2021-04-12 19:39                                                 ` Alan Third
2021-04-13  1:25                                                   ` Stefan Kangas
2021-04-13  7:35                                                     ` Alan Third
2021-04-13 10:39                                                       ` Stefan Kangas
2021-04-13 19:50                                                         ` Alan Third
2021-04-13 22:44                                                           ` Stefan Kangas
2021-04-14  6:46                                                           ` Eli Zaretskii
2021-04-15 15:37                                                             ` Alan Third
2021-04-15 15:50                                                               ` Eli Zaretskii
2021-04-15 17:10                                                                 ` Alan Third
2021-04-11 21:57                                       ` Dmitry Gutov
2021-04-09 23:16                                   ` Alan Third
2021-04-10  0:55                                     ` Stefan Kangas
2021-04-10  7:23                                       ` Eli Zaretskii
2021-04-10  9:17                                         ` Alan Third
2021-04-10  9:25                                           ` Eli Zaretskii
2021-04-08 17:22             ` [External] : Re: Improvement proposals for `completing-read' Drew Adams
2021-04-08 18:33               ` Drew Adams
2021-04-07 23:11       ` Drew Adams
2021-04-08  7:56       ` Eli Zaretskii
2021-04-07 18:39 ` Jean Louis
2021-04-07 19:49   ` Daniel Mendler
2021-04-07 22:16 ` Dmitry Gutov
2021-04-08  8:37   ` Daniel Mendler
2021-04-08 20:44     ` Dmitry Gutov
2021-04-08 21:30       ` Daniel Mendler
2021-04-10  2:21         ` Dmitry Gutov
2021-04-10  9:18           ` Daniel Mendler
2021-04-11  0:51             ` Dmitry Gutov [this message]
2021-04-11 13:08               ` Daniel Mendler
2021-04-12  0:32                 ` Dmitry Gutov
2021-04-12  0:40                   ` Daniel Mendler
2021-04-12 10:47                     ` Dmitry Gutov
2021-04-12 11:04                       ` Daniel Mendler
2021-04-14  0:00                         ` Dmitry Gutov
2021-04-14 10:44                           ` Daniel Mendler
2021-04-07 23:49 ` [External] : " Drew Adams
2021-04-08  9:29   ` Daniel Mendler
2021-04-08 17:19     ` Drew Adams
2021-04-09 11:19       ` Jean Louis
2021-04-09 11:47         ` Daniel Mendler
2021-04-09 17:22         ` Drew Adams
2021-04-09 17:41           ` Daniel Mendler

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=759ed5ae-8d58-e73b-244b-08bd86aafb2d@yandex.ru \
    --to=dgutov@yandex.ru \
    --cc=emacs-devel@gnu.org \
    --cc=mail@daniel-mendler.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).