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

Re: PATCH: 3.1.6-bart-7: Self-loading auto-functions



Bart Schaefer wrote:

> purposes of making `eval $(functions)' work was equally annoying.  Further,
> it might be useful to differentiate an actual autoloaded function from one
> that merely calls "autoload -X".

Also, does it differentiate at all between an autoloaded function that
was autoloaded with -U at all. I only actually realised what the -U does
when checking the documentation now (suppressing alias expansion). It
might be clear if this would expand to 'builtin autoload -XU' (if it
doesn't already).

The autoload -X seems like it could be interesting from the perspective
of using it intentionally in a function so that it does some extra stuff
the first time it is executed. or to force it to reload every time it is
run (though I don't think that can be done without infinite recursion or
reloading after running). The latter could be especially useful when I'm
debugging completion functions - it can be quite tedious to constantly
have to do unfunction _foo; autoload _foo. Actually, it'd be useful to
have an option to autoload (-f for force maybe) which does the
unfunction first.

Do these changes allow you to now declare local functions (which was
what started this all off). From what I can make out, it should work
with typeset +h functions with the parameter module loaded. I can see
one possible problem in this approach. From what I can gather, the +h
option saves the value of the parameter, clears it and it is restored
when returning. Does this mean that after typeset +h functions, all
existing functions are lost until you return? 
How efficiently would this work - saving and restoring all the functions
might not be very efficient. Anyway, I certainly agree that local
functions would be useful to have. I'm often forgetting that nested
functions aren't local.

Oliver Kiddle



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