gpt4 book ai didi

lua - _VERSION 是 Lua 5.1 中唯一剩下的全局变量吗?

转载 作者:行者123 更新时间:2023-12-02 02:20:41 25 4
gpt4 key购买 nike

对 Lua 5.0 文档中对 _LOADEDLUA_PATH_ALERT 等内容的引用感到困惑(我无法在 Lua 中使用这些内容) 5.1),我发现所有这些都已被删除,并将功能放在其他地方。我是否正确地认为 Lua 5.1 中剩下的唯一一个全局变量是 _VERSION

最佳答案

文档似乎认为情况几乎是这样......

_G A global variable (not a function) that holds the global environment (that is, _G._G = _G). Lua itself does not use this variable; changing its value does not affect any environment, nor vice-versa. (Use setfenv to change environments.)

看起来还有 _PROMPT 和 _PROMPT2,但仅限于交互使用独立 lua 时:

If the global variable _PROMPT contains a string, then its value is used as the prompt. Similarly, if the global variable _PROMPT2 contains a string, its value is used as the secondary prompt (issued during incomplete statements). Therefore, both prompts can be changed directly on the command line or in any Lua programs by assigning to _PROMPT.

关于lua - _VERSION 是 Lua 5.1 中唯一剩下的全局变量吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/146704/

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