来源:Lua
浏览 366
扫码
分享
2020-07-02 07:45:06
8.1 – Incompatibilities in the Language
- The coercion of strings to numbers in arithmetic and bitwise operations has been removed from the core language. The string library does a similar job for arithmetic (but not for bitwise) operations using the string metamethods. However, unlike in previous versions, the new implementation preserves the implicit type of the numeral in the string. For instance, the result of
"1" + "2"
now is an integer, not a float. - Literal decimal integer constants that overflow are read as floats, instead of wrapping around. You can use hexadecimal notation for such constants if you want the old behavior (reading them as integers with wrap around).
- The use of the
__lt
metamethod to emulate __le
has been removed. When needed, this metamethod must be explicitly defined. - The semantics of the numerical for loop over integers changed in some details. In particular, the control variable never wraps around.
- A label for a goto cannot be declared where a label with the same name is visible, even if this other label is declared in an enclosing block.
- When finalizing an object, Lua does not ignore
__gc
metamethods that are not functions. Any value will be called, if present. (Non-callable values will generate a warning, like any other error when calling a finalizer.)
当前内容版权归
Lua 或其关联方所有,如需对内容或内容相关联开源项目进行关注与资助,请访问
Lua .