gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-02 23:00:26 27 4
gpt4 key购买 nike

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 '-'.

我的解释:

  1. 绝对清晰(Windows/其他系统的示例使其万无一失)
  2. 路径字符串中可以有多个路径。它们以此符号分隔(默认为 ;)。
  3. 每当 Lua 在路径字符串(默认为 ?)中找到此字符时,它都会将其替换为提供给 require 包的模块名称。 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.

    这个符号(默认情况下是-)是为了同时提供不同版本的库——可能带有指向最新版本的无前缀符号链接(symbolic link),以便可以访问同一个库在两个路径上(即在两个模块名称下),但只有一个 C 符号名称?

  • 最佳答案

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

    5:我相信版本控制和项目 fork 是其背后的原因。

    关于lua - Lua `package.config` 中的最后几行是什么意思?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31904392/

    27 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com