lua 5.4

After two years of development, on June 29, a new version of the Lua programming language, 5.4, was quietly and imperceptibly released.

Lua is a simple, interpreted programming language that can be easily embedded into applications. Due to these qualities, Lua is widely used as a language for extending or describing the configuration of programs (in particular, computer games). Lua will be distributed under the MIT license.

The previous version (5.3.5) was released on July 10, 2018.

Main changes in the new version

  • new garbage collector based on generations (generational). In the collectgarbage function, the setpause and setstepmul parameters have been deprecated and the incremental parameter is recommended instead;

  • a new function for issuing warn warnings with the ability to disable their display;

  • the new implementation of math.random uses the xoshiro256** algorithm instead of the one provided by libc and initializes the generator with a random number;

  • constant variables;

  • “to-be-closed” variables are local constants for which the __close method is executed when the scope is exited;

  • new function lua_resetthread - clears the stack and closes all "closed" variables;

  • new function coroutine.close - closes the specified coroutine and all its "closable" variables;

  • user data (userdata) can contain a set of values ​​accessed by index. New functions have been introduced to work with them: lua_newuserdatauv, lua_setiuservalue and lua_getiuservalue;

  • debugging information about parameters and return values ​​of functions is available;

  • if an integer index is used in the for loop and an overflow occurs, the loop ends;

  • added an optional argument to the string.gmatch function that specifies the offset from the beginning of the string to search for matches;

  • the functions of implicit conversion of strings to numbers have been moved to the string library, their behavior has changed. For example, the result of the operation "1" + "2" is now an integer, not a floating point number;

  • in the memory allocation function, an error can occur when a memory block is reduced;

  • new format character 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 allowed);

  • integer constants that are outside the range of values ​​are converted to floating numbers (previously bit clipping occurred);

  • the __lt metamethod is no longer used to emulate the __le metamethod, if necessary, the __le metamethod must be set explicitly;

  • a label for a goto statement cannot be created if a label with the same name already exists in the current scope (even if it was defined in the outer scope);

  • the __gc metamethod can be more than just a function. If the attempt to call the method fails, a warning will be displayed;

  • the print function does not call tostring for each argument, but uses its own internal transformations;

  • the io.lines function returns a set of four values ​​instead of one, to emulate the old behavior, enclose the call in parentheses if you substitute it as a parameter when calling another function.

Source: linux.org.ru

Add a comment