lua-users home
lua-l archive

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


On Sat, Jan 8, 2022 at 9:22 PM Flyer31 Test wrote:
PS: Why do you think that Lua has lost its "simple coding style" since
5.3?

I'm not talking about "coding style".
Let's define "complexity of a language" as the amount of information you have to load into your brains for successful programming.
Lua 5.2 was more simple (and more attractive to me) because of the single numeric type.
In Lua 5.3+ every arithmetic _expression_ might be dangerous because of occasional integer wraparound.
For example, you are writing an _expression_ for floating point values, but some of the variables might sometimes contain integers, they may come from user input, from function's arguments, from the length operator, from str:byte(), from next(t), from simple constants you have forgotten to convert into floats (such as x=1). In other words, Lua always tries to poison your arithmetic with integers, and you have to fight back these attacks :-)
You have to make sure that either the result of a multiplication is always within the integers range or at least one of the operands is float.
That's a new complexity and new source of errors Lua 5.2 did not have.

Was Lua 5.3 designed with the assumption that integer wraparound is a useful feature? :-)