From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 25447 invoked by alias); 12 Sep 2015 23:04:00 -0000 Mailing-List: contact zsh-users-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Users List List-Post: List-Help: X-Seq: 20546 Received: (qmail 8263 invoked from network); 12 Sep 2015 23:03:57 -0000 X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.0 X-Authority-Analysis: v=2.1 cv=X+5rdgje c=1 sm=1 tr=0 a=jE+ovs97kTJM1dD6JNRapQ==:117 a=jE+ovs97kTJM1dD6JNRapQ==:17 a=N659UExz7-8A:10 a=zaafH0kMK9LHaFbMcQYA:9 a=pILNOxqGKmIA:10 Message-id: <55F4AF59.70606@eastlink.ca> Date: Sat, 12 Sep 2015 16:03:53 -0700 From: Ray Andrews User-Agent: Mozilla/5.0 (X11; Linux i686; rv:31.0) Gecko/20100101 Icedove/31.7.0 MIME-version: 1.0 To: zsh-users@zsh.org Subject: Re: Announce of Zsh Navigation Tools References: <55F465E6.1040405@eastlink.ca> <2125131442086868@web14o.yandex.ru> <55F4930A.40608@eastlink.ca> <150912151040.ZM12254@torch.brasslantern.com> In-reply-to: <150912151040.ZM12254@torch.brasslantern.com> Content-type: text/plain; charset=windows-1252; format=flowed Content-transfer-encoding: 7bit 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?