After two years of development, on June 29, the new version of the Lua programming language – 5.4 – was quietly released.
Lua is a simple interpreted programming language that easily integrates into applications. Due to these qualities, Lua is widely used as an extension language or for configuration description of programs (particularly in computer games). Lua is distributed under the MIT License.
The previous version (5.3.5) was released on July 10, 2018.
Key changes in the new version
a new generational garbage collector. The parameters setpause and setstepmul in the collectgarbage function are deprecated; it is recommended to use the incremental parameter instead;
a new function for issuing warnings warn with the ability to disable their display;
the new implementation of math.random uses the xoshiro256** algorithm instead of the provided libc and initializes the generator with a random number;
constant variables;
to-be-closed variables – local constants for which the __close method is executed upon exiting their scope;
a new function lua_resetthread – clears the stack and closes all to-be-closed variables;
a new function coroutine.close – closes the specified coroutine and all its to-be-closed variables;
userdata can contain a set of values accessible by index. New functions have been introduced for working with them: lua_newuserdatauv, lua_setiuservalue, and lua_getiuservalue;
debugging information about function parameters and return values is available;
if an integer index is used in a for loop and overflow occurs, the loop terminates;
an optional argument has been added to the string.gmatch function to specify an offset from the start of the string for finding matches;
implicit conversion functions for strings to numbers have been moved to the string library, and their behavior has changed. For example, the result of the operation "1" + "2" is now an integer, not a floating-point number;
an error may occur in the memory allocation function when reducing the memory block;
a new formatting symbol in the string.format function – %p (for pointers);
the utf8 library accepts character codes up to 2³¹ (when a special flag is specified, without it only codes up to 0x10FFFF are allowed and surrogates are not permitted);
Integer constants that exceed the value range are converted to floating-point numbers (previously, this resulted in bit truncation);
The __lt metamethod is no longer used to emulate the __le metamethod; if necessary, the __le metamethod must be explicitly set;
A label for the goto statement cannot be created if a label with the same name already exists in the current scope (even if it was defined in an outer scope);
The __gc metamethod can be more than just a function. If calling the method fails, a warning will be issued;
The print function does not call tostring for each argument but uses its internal conversions;
The io.lines function returns a set of four values instead of one; to emulate the old behavior, enclose the call in parentheses if substituting it as a parameter in another function call.
Source: linux.org.ru
