summaryrefslogtreecommitdiff
path: root/manual
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2018-08-24 10:17:54 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2018-08-24 10:17:54 -0300
commit8c8a91f2ef7acccb99e3737913faad8d48b39571 (patch)
tree0807151944b7f7fd00eedfcfe94b4ee26fe25b21 /manual
parentf99509581ee73c1c2dbddb3398e87c098771d31f (diff)
downloadlua-github-8c8a91f2ef7acccb99e3737913faad8d48b39571.tar.gz
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.of21
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.
@item{@idx{__le}|
the less equal (@T{<=}) operation.
-Unlike other operations,
-the less-equal operation can use two different events.
-First, Lua looks for the @idx{__le} metamethod in both operands,
-like in the less than operation.
-If it cannot find such a metamethod,
-then it will try the @idx{__lt} metamethod,
-assuming that @T{a <= b} is equivalent to @T{not (b < a)}.
-As with the other comparison operators,
-the result is always a boolean.
-(This use of the @idx{__lt} event can be removed in future versions;
-it is also slower than a real @idx{__le} metamethod.)
+Behavior similar to the less than operation.
}
@item{@idx{__index}|
@@ -1643,7 +1633,8 @@ all operations @emphx{wrap around},
according to the usual rules of two-complement arithmetic.
(In other words,
they return the unique representable integer
-that is equal modulo @M{2@sp{64}} to the mathematical result.)
+that is equal modulo @M{2@sp{n}} to the mathematical result,
+where @M{n} is the number of bits of the integer type.)
}
@sect3{bitwise| @title{Bitwise Operators}
@@ -8537,6 +8528,12 @@ For instance, the result of @T{"1" + "2"} now is an integer,
not a float.
}
+@item{
+The use of the @idx{__lt} metamethod to emulate @id{__le}
+has been removed.
+When needed, this metamethod must be explicitly defined.
+}
+
}
}