The Lua specs talk about package.config (the added digit I added):
- The first line is the directory separator line. The default is "
\ " for Windows and " / " for all other systems. - The second line is the character that separates the patterns in the path. The default value is "
; ". - The third line is a line that marks the substitution points in the template. The default value is "
? ". - The fourth line is the line that is replaced by the executable directory in the Windows path. The default value is "
! ". - The fifth line is a character to ignore all text before creating the function name
luaopen_ . The default is " - ".
My rephrasing:
- Absolutely clear (example for Windows / other systems makes it flawless)
- There can be several paths in a path line. They are separated by this symbol (
; by default). - In cases where Lua finds this character in the path string (
? By default), it will replace it with the module name specified in the require or package.searchpath functions, and check if this file exists.
So far, so good, but the last two lines are not entirely clear to me.
- Why does he say "on the way to Windows"? Does this on other platforms, it does not matter? If so, why?
It took me a while to figure this out, but in the end another piece of specs gave me a hint:
The name of this C function is the string " luaopen_ ", combined 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 before (and includes) the first hyphen is removed. For example, if the module name is a.v1-bc , the function name will be luaopen_b_c .
Thus, this symbol ( - by default) is designed to simultaneously create different versions of the library available - potentially with an unrelated symbolic link to the latest version, so that the same library is accessible in two ways (i.e. under two module names) but with only one C character?
source share