Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: Announce of Zsh Navigation Tools

On 09/12/2015 03:10 PM, Bart Schaefer wrote:
On Sep 12,  2:03pm, Ray Andrews wrote:
} What are the pros and cons of doing things that way vs. what might
} seem to be the more obvious function definition? It's more compact,
} but then requires the special calling via autoload. I expect there
} will be some substantial difference.

There isn't (intended to be) any execution-time difference.  If you
can find one, it's probably a bug, except for the variations that
are implied by (misapplication of) the -z / -k options of autoload.

The main benefit is that you don't have loaded into memory those
functions that you don't use. The not-yet-loaded form of an autoloaded
function is very small.  You also avoid a lot of the startup time of
parsing all those files.  E.g., the completion system is now nearly
10MB; why read all of that when most of it may never be used?

I suppose, conversely, the drawback is that there may be a delay for
parsing, the first time any such function is executed.

Another drawback is that you can't easily switch among different
emulation modes without taking special precautions, because the parse
will always be applied using the mode at the time of first execution
rather than the mode when the autoload command was issued.  We could
probably stand an autoload option to apply "sticky emulation."

Ah ...

I load my own functions thusly:

    for aa in /aWorking/Zsh/Source/*;  do source $aa; done

... but as I understand you, autoload only 'really' loads things when they are actually called, so that has to be more efficient. That immediately makes me want do something like this:

    for aa in /aWorking/Zsh/Source/*; do autoload $aa; done

... remembering of course that things need to be rewritten to look like scripts. As to emulation, that's still way over my head.

BTW, looking at $fpath, it sure is laborious. Do we, could wehave some sort of automatic subdirectory inclusion? Sorta: /usr/share/zsh/functions/**/ ... or something like that?

Messages sorted by: Reverse Date, Date, Thread, Author