当前位置 : 主页 > 网络编程 > lua >

Lua的`package.config`中的最后几行是什么意思?

来源:互联网 收集:自由互联 发布时间:2021-06-23
Lua specs say about package.config (由我添加的编号): 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
Lua specs say about package.config(由我添加的编号):

  1. The first line is the directory separator string. Default is ‘\‘ for Windows and ‘/‘ for all other systems.
  2. The second line is the character that separates templates in a path. Default is ‘;‘.
  3. The third line is the string that marks the substitution points in a template. Default is ‘?‘.
  4. The fourth line is a string that, in a path in Windows, is replaced by the executable’s directory. Default is ‘!‘.
  5. The fifth line is a mark to ignore all text before it when building the luaopen_ function name. Default is ‘-‘.

我的解释:

>绝对清晰(Windows /其他系统的示例使其成为傻瓜证明)
>路径字符串中可以有多个路径.它们由此符号分隔(默认情况下为;).
>无论Lua在路径字符串中找到此字符(默认情况下为?),它都会将其替换为提供给require或package.searchpath函数的模块名称,并检查该文件是否存在.

到目前为止,这么好,但最后两行对我来说并不完全清楚.

>为什么它说“在Windows中的路径”?这是否意味着在其他平台上,这没有任何意义?如果是这样,为什么?
>我花了一段时间来理解这一点,但最终another part of the specs给了我一个提示:

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 is a.v1-b.c, the function name will be luaopen_b_c.

这个符号( – 默认情况下)也是如此,它可以同时提供不同版本的库 – 可能是对最新版本的无前缀符号链接,以便可以在两个路径上访问相同的库(即在两个模块名称下) ,但只有一个C符号名称?

4:Linux应用程序在系统范围内安装了库;但是,对于Windows,库可以安装在当前目录中.

5:我认为版本控制和项目分叉将是背后的原因.

网友评论