lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


Hi!
This is "Nitpicking on Wednesdays".
 
 
1)
Lua 5.4 (as of 2019-Jan-30 on Github) Visual Studio 2010 warning
lfunc.c(141) : warning C4244: 'function' : conversion from '__int64' to 'int', possible loss of data
 
 
2)
A constant defined in lopcodes.h is never used
   #define MAXARG_Cx    ((1<<(SIZE_C + 1))-1)
 
 
3)
There is a typo in "manual.of" in section "To-be-closed Variables" in Lua 5.4 on Github
"\emph" -> "@emph"
 
 
4)
OP_CALL is described as R(A), ... ,R(A+C-2) := R(A)(R(A+1), ... ,R(A+B-1))
The note says:  (*) In OP_CALL, if (B == 0) then B = top.
Probably, "B = top" should be replaced with "A+B = top"?
 
 
5)
The S2N-coercion (from string to number) is somewhat anarchic:
   local x = "2" | 3   -- coercion fails
   local x = "2" + 3   -- coercion results in integer value
   for x = "2", 3 do   -- coercion results in float value
The coercion logic is unexpected and non-obvious.
Even disabling of auto-S2N-coercion would be a lesser surprise  :-)
 
The coercion creates an illusion that in Lua you could use strings instead of numbers.
But it's difficult to describe when you can rely on such coercion and when you can not.
S2N-coercion isn't consistent across all the numeric operations:
   "10" - "9" > 0             -- true
   "10" > "9"                 -- false
   math.max("10", "9")=="10"  -- false
S2N-coercion is full of traps, using it is considered a bad practice, and it is becoming more complicated.
Is it the right moment to remove auto-S2N-coercion from Lua?
 
 
6)
The new syntax "local * toclose" is weird.
Of course, such syntax would be useful if other modifiers (words after asterisk) are expected to be introduced in future Lua versions.
Otherwise, more simple syntax for "to-be-closed" variables might be nicer.
 
Currently:
   local n, str = 42, "abc"
   local * toclose cl = obj
 
Possible suggestions:
   local n, *cl, str = 42, obj, "abc"
or
   local n, (cl), str = 42, obj, "abc"
 
A pun: to mark a variable "to-be-closed", we make its name enclosed in parentheses.

-- Egor