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:
;
by default).?
by default), it will replace it with the module name supplied to the require
or package.searchpath
functions and check whether that file exists.So far, so good, but the last two lines aren't entirely clear to me.
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?
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With