gpt4 book ai didi

lua - Lua中双冒号的作用是什么?

转载 作者:行者123 更新时间:2023-12-02 04:22:49 28 4
gpt4 key购买 nike

我知道 Lua 5.3 版本不久前已经发布,但直到现在才有理由访问在线文档。我可能是错的,但我不相信能记住双冒号 :: 的用法,就像它在那里被广泛使用一样。

我发现它像其他标记一样被认为是“特殊标记”(大于、小于、星号等),但我知道它们的用途。

在Lua中使用它们的目的是什么?

最佳答案

:: 在 Lua 中仅用于一件事 *:

Declaring labels for jumping with goto.

goto label
::label::

The goto statement transfers the program control to a label. For syntactical reasons, labels in Lua are considered statements too:

stat ::= goto Name
stat ::= label
label ::= ‘::’ Name ‘::’

A label is visible in the entire block where it is defined, except inside nested blocks where a label with the same name is defined and inside nested functions. A goto may jump to any visible label as long as it does not enter into the scope of a local variable.

Labels and empty statements are called void statements, as they perform no actions.

* 我不认为在 Lua 本身的文档使用中广泛使用扩展 BNF。

关于lua - Lua中双冒号的作用是什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34623542/

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