emacs-devel
[Top][All Lists]
Advanced

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

Re: Generic autoloading? [Was Patch: perform autoloading when docs is mi


From: Stefan Monnier
Subject: Re: Generic autoloading? [Was Patch: perform autoloading when docs is missing from autoload object]
Date: Fri, 17 Sep 2021 15:36:33 -0400
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux)

> Just in case, is it possible to provide a generic autoload mechanism
> that run arbitrary function to load the missing function, 
> instead of hardcoded to basically a REQUIRE?

I think if it doesn't end up loading a file, and isn't bound to
the `symbol-function` cell of a symbol, then it's probably too different
from our autoloads to be worth trying to shoehorn it into the existing system.

> Currently I can fake it with a closure that knows where it is
> and replace itself once called.

I think the fix is to remove the word "fake" in the description ;-)

> But it feels like reimplementing the same thing twice.

I haven't looked at your code, but if what you fetch lazily is itself
a function, then I suspect that your "faking code" is clean, short, and
reliable, and there isn't much to share with the autoload code (other
than a philosophical similarity).

> (I think current autoload can also be implemented in pure Elisp
> in this way,

More or less, yes (tho it gets more costly in terms of heap usage).
Also, we have accrued various subtle details that are inconvenient to
mimic (e.g. various places call `autoload-do-load` manually rather than
just calling the function in order to get a bit more control over what
happens when).


        Stefan




reply via email to

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