Lua =运算符作为print

Dre*_*mer 5 lua

在Lua中,使用不带l值的=运算符似乎等同于print(r值),这里有一些在Lua独立解释器中运行的示例:

> = a
nil
> a = 8
> = a
8
> = 'hello'
hello
> = print
function: 003657C8
Run Code Online (Sandbox Code Playgroud)

等等...

我的问题是:在哪里可以找到=运算符的这种用法的详细描述?它是如何工作的?是否意味着特殊的默认l值?我想问题的根源在于我不知道在Google中输入什么内容以查找有关它的信息:-)

编辑:

谢谢你的答案,你是对的,这是翻译的一个特点.愚蠢的问题,因为我不知道哪个理由让我完全忽略了这一点.我应该避免在早晨咖啡之前发布:-)为了完整起见,这里是解释器中处理这个问题的代码:

while ((status = loadline(L)) != -1) {
  if (status == 0) status = docall(L, 0, 0);
  report(L, status);
  if (status == 0 && lua_gettop(L) > 0) {  /* any result to print? */
    lua_getglobal(L, "print");
    lua_insert(L, 1);
    if (lua_pcall(L, lua_gettop(L)-1, 0, 0) != 0)
      l_message(progname, lua_pushfstring(L,
                           "error calling " LUA_QL("print") " (%s)",
                           lua_tostring(L, -1)));
  }
}
Run Code Online (Sandbox Code Playgroud)

编辑2:

要真正完成,关于在堆栈上推送值的整个技巧是在"pushline"函数中:

if (firstline && b[0] == '=')  /* first line starts with `=' ? */
  lua_pushfstring(L, "return %s", b+1);  /* change it to `return' */
Run Code Online (Sandbox Code Playgroud)

Hug*_*len 15

引用手册页:

在交互模式下...如果一行以'='开头,则lua显示该行剩余部分中所有表达式的值.表达式必须用逗号分隔.