diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2018-08-24 10:17:54 -0300 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2018-08-24 10:17:54 -0300 |
commit | 8c8a91f2ef7acccb99e3737913faad8d48b39571 (patch) | |
tree | 0807151944b7f7fd00eedfcfe94b4ee26fe25b21 /manual | |
parent | f99509581ee73c1c2dbddb3398e87c098771d31f (diff) | |
download | lua-8c8a91f2ef7acccb99e3737913faad8d48b39571.tar.gz lua-8c8a91f2ef7acccb99e3737913faad8d48b39571.tar.bz2 lua-8c8a91f2ef7acccb99e3737913faad8d48b39571.zip |
Deprecated the emulation of '__le' using '__lt'
As hinted in the manual for Lua 5.3, the emulation of the metamethod
for '__le' using '__le' has been deprecated. It is slow, complicates
the logic, and it is easy to avoid this emulation by defining a proper
'__le' function.
Moreover, often this emulation was used wrongly, with a programmer
assuming that an order is total when it is not (e.g., NaN in
floating-point numbers).
Diffstat (limited to 'manual')
-rw-r--r-- | manual/manual.of | 21 |
1 files changed, 9 insertions, 12 deletions
diff --git a/manual/manual.of b/manual/manual.of index 5a8b1b2c..47a551bf 100644 --- a/manual/manual.of +++ b/manual/manual.of | |||
@@ -474,17 +474,7 @@ The result of the call is always converted to a boolean. | |||
474 | 474 | ||
475 | @item{@idx{__le}| | 475 | @item{@idx{__le}| |
476 | the less equal (@T{<=}) operation. | 476 | the less equal (@T{<=}) operation. |
477 | Unlike other operations, | 477 | Behavior similar to the less than operation. |
478 | the less-equal operation can use two different events. | ||
479 | First, Lua looks for the @idx{__le} metamethod in both operands, | ||
480 | like in the less than operation. | ||
481 | If it cannot find such a metamethod, | ||
482 | then it will try the @idx{__lt} metamethod, | ||
483 | assuming that @T{a <= b} is equivalent to @T{not (b < a)}. | ||
484 | As with the other comparison operators, | ||
485 | the result is always a boolean. | ||
486 | (This use of the @idx{__lt} event can be removed in future versions; | ||
487 | it is also slower than a real @idx{__le} metamethod.) | ||
488 | } | 478 | } |
489 | 479 | ||
490 | @item{@idx{__index}| | 480 | @item{@idx{__index}| |
@@ -1643,7 +1633,8 @@ all operations @emphx{wrap around}, | |||
1643 | according to the usual rules of two-complement arithmetic. | 1633 | according to the usual rules of two-complement arithmetic. |
1644 | (In other words, | 1634 | (In other words, |
1645 | they return the unique representable integer | 1635 | they return the unique representable integer |
1646 | that is equal modulo @M{2@sp{64}} to the mathematical result.) | 1636 | that is equal modulo @M{2@sp{n}} to the mathematical result, |
1637 | where @M{n} is the number of bits of the integer type.) | ||
1647 | } | 1638 | } |
1648 | 1639 | ||
1649 | @sect3{bitwise| @title{Bitwise Operators} | 1640 | @sect3{bitwise| @title{Bitwise Operators} |
@@ -8537,6 +8528,12 @@ For instance, the result of @T{"1" + "2"} now is an integer, | |||
8537 | not a float. | 8528 | not a float. |
8538 | } | 8529 | } |
8539 | 8530 | ||
8531 | @item{ | ||
8532 | The use of the @idx{__lt} metamethod to emulate @id{__le} | ||
8533 | has been removed. | ||
8534 | When needed, this metamethod must be explicitly defined. | ||
8535 | } | ||
8536 | |||
8540 | } | 8537 | } |
8541 | 8538 | ||
8542 | } | 8539 | } |