问题
The Lua specs say about package.config (numbering added by me):
- The first line is the directory separator string. Default is '
\' for Windows and '/' for all other systems.- The second line is the character that separates templates in a path. Default is '
;'.- The third line is the string that marks the substitution points in a template. Default is '
?'.- The fourth line is a string that, in a path in Windows, is replaced by the executable's directory. Default is '
!'.- The fifth line is a mark to ignore all text before it when building the
luaopen_function name. Default is '-'.
My paraphrasing:
- Absolutely clear (example for Windows/other systems makes it fool proof)
- There can be multiple paths in a path string. They are separated by this symbol (
;by default). - Wherever Lua finds this character in the path string (
?by default), it will replace it with the module name supplied to therequireorpackage.searchpathfunctions and check whether that file exists.
So far, so good, but the last two lines aren't entirely clear to me.
- Why does it say "in a path in Windows"? Does that mean on other platforms, this doesn't have any significance? If so, why?
It took me a while to make sense of this, but eventually another part of the specs gave me a hint:
The name of this C function is the string "
luaopen_" concatenated with a copy of the module name where each dot is replaced by an underscore. Moreover, if the module name has a hyphen, its prefix up to (and including) the first hyphen is removed. For instance, if the module name isa.v1-b.c, the function name will beluaopen_b_c.So is this symbol (
-by default) intended to make different versions of a library available at the same time – potentially with an unprefixed symlink to the newest version so that the same library would be accessible on two paths (i.e. under two module names), but with only one C symbol name?
回答1:
4: Applications for Linux have libraries installed system-wide; however, for Windows, libraries can be installed in the current directory.
5: Versioning and project forking, I believe, would be the reason behind this.
来源:https://stackoverflow.com/questions/31904392/what-do-the-last-lines-in-luas-package-config-mean