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

Should defining a reference to an autoload parameter load it?



I noticed that the simple fact of defining a reference to an autoload parameter triggers its loading:

zmodload -ap | grep SRANDOM || echo "SRANDOM was loaded"
typeset -n ref=SRANDOM
zmodload -ap | grep SRANDOM || echo "SRANDOM was loaded"
Output:
SRANDOM (zsh/random)
SRANDOM was loaded

I find it strange that the simple fact of defining a reference triggers any loading. I would rather expect this to only happen the first time that the reference is expanded or assigned to.

I'm asking because if this is desired and expected then some code might need to be updated to ensure that this happens in all cases. I don't have a specific example in mind but I seem to remember seeing code that would fail to trigger the loading.

If on the contrary this is undesired, then obviously some code needs to be fixed to prevent the early loading.

Or do we just not care because loading modules is no big deal? In that case, no action is required.

Philippe



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