aboutsummaryrefslogtreecommitdiff
path: root/ltm.c
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 /ltm.c
parentf99509581ee73c1c2dbddb3398e87c098771d31f (diff)
downloadlua-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 'ltm.c')
-rw-r--r--ltm.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/ltm.c b/ltm.c
index 1c1a18b7..5c148180 100644
--- a/ltm.c
+++ b/ltm.c
@@ -188,6 +188,7 @@ int luaT_callorderTM (lua_State *L, const TValue *p1, const TValue *p2,
188 TMS event) { 188 TMS event) {
189 if (callbinTM(L, p1, p2, L->top, event)) /* try original event */ 189 if (callbinTM(L, p1, p2, L->top, event)) /* try original event */
190 return !l_isfalse(s2v(L->top)); 190 return !l_isfalse(s2v(L->top));
191#if defined(LUA_COMPAT_LT_LE)
191 else if (event == TM_LE) { 192 else if (event == TM_LE) {
192 /* try '!(p2 < p1)' for '(p1 <= p2)' */ 193 /* try '!(p2 < p1)' for '(p1 <= p2)' */
193 L->ci->callstatus |= CIST_LEQ; /* mark it is doing 'lt' for 'le' */ 194 L->ci->callstatus |= CIST_LEQ; /* mark it is doing 'lt' for 'le' */
@@ -197,6 +198,7 @@ int luaT_callorderTM (lua_State *L, const TValue *p1, const TValue *p2,
197 } 198 }
198 /* else error will remove this 'ci'; no need to clear mark */ 199 /* else error will remove this 'ci'; no need to clear mark */
199 } 200 }
201#endif
200 luaG_ordererror(L, p1, p2); /* no metamethod found */ 202 luaG_ordererror(L, p1, p2); /* no metamethod found */
201 return 0; /* to avoid warnings */ 203 return 0; /* to avoid warnings */
202} 204}