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

Re: autoload



Just so no one else is confused ...

On Sep 22, 10:33am, Ray Andrews wrote:
}
} > zcompile lets you do two things:  compile a single file to be read by
} > source (*) or pack multiple files into an archive to be processed
} > by autoload.
} >
} > (*) But this is constrained in that both the original file and the
} > compiled file have to exist size-by-side, so that source can choose
} > the newer of the two.  This constraint isn't strictly necessary.
} 
} Well therewego.  Previously you're saying that these .zwc should not be
} in the same dir, now they should be in the same dir.

Two different use cases:

(1) Packing up multiple files into a composite ZWC?  Don't put the
    composite alongside the files packed in it.  This is the case we
    started out talking about two dozen messages ago.  Makes sense
    only for autoload.

(2) Packing one file into one correspondingly-named ZWC?  Put the ZWC
    alongside the origin file.  Works for source or autoload, but in
    the autoload case this must be one-function/one-file/same-name.

The autoload search is straightforward:  $fpath order comes first.
If, while searching fpath in order, a pair of files "x" and "x.zwc"
is found, read the newer one.  As a special case of this, if "x" is
actually a directory listed in fpath, assume "x.zwc" contains all the
same files as "x/".

The "source" (and ".") search rule is similar, except using $path and
without the directory special case.

}      $ autoload my_function
}      $ source /functions/myfunction
} 
} ... I get the sourced version.

Yes, because in this case you clobbered the autoload declaration by
loading the full function definition on top of it with "source".

}      $ source /functions/myfunction
}      $ autoload my_function
} 
} ... I get the version in the .zwc found on FPATH.

No, you still get the one from the "source" command, because autoload
won't replace an existing function definition.  The only way to ever
get the version found on fpath is by never doing the "source" at all.



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