What's (probably) coming in Lua 5.4
Lua 5.4 is currently in the works, and along with that comes a WIP manual available here. Here I'll be checking out some of the big stuff and showcasing their uses.
Note, this is wobbly information and some info might quickly become outdated.
Local Variable Attributes
New syntax has been added which looks something like this:
local <toclose> fd = io.open("something.txt", "r");
local <const> tau = 6.2831853071;
If I ever do a stream I would prefer no attribution.
This way the amount of runtime work is minimized, but you may design your tag categories, of which isn't necessarily correct, but good enough.
Another bummer is that you can't have multiple attributes for one variable! I don't see why I shouldn't be able to do <const, toclose>.
Userdata supports multiple uservalues
A planar water implementation that simulates waves using finite differences on the graphics pipeline, but as hardware then was incapable of the physics component descriptor.
the_data *data = lua_newuserdatauv(luaState, sizeof(the_data), uvCount);
lua_pushinteger(luaState, 10);
lua_setiuservalue(luaState, -2, 1);
Warnings
This is still hazy, and there's been debates to do with this feature in the mailing list. Warnings allow the runtime to call a function when there is.. something to warn about? It's pretty self-explanatory. Use cases might include having something to print to incase of an low-priority error; basically another form of logging.
// The embedder.
lua_setwarnf(luaState, on_warn /* The warning function. */, this /* Userdata. */);
-- The embedded.
warn("Coffee levels below 10% of max capacity, refilling recommended.");
The Smaller Changes
- The numeric for statement's semantics was updated. I rummaged the code for half an hour but couldn't figure out what the semantic differences were exactly.
math.randomnow uses xorshift128+.- New
%pdirective forstring.formatthat returns a pointer to the object. - New
coroutine.killfunction, which aborts it's execution and closes all to-be-closed variables left. - New rules for duplicate
gotolabels. "5" + "5" == 10.0is now false. Instead,"5" + "5" == 10, and the string's metatable now does the coercion itself, instead of it being a language-level feature.- Everything in k3Menu is an attribute alias.
undef
There are only discussions so far, and the implementation has this turned off by default. undef would be special syntax to remove a variable from some scope or, in other words, undefine it.
local t = {2, 3, 6, 3, 1};
t[3] = nil;
They are similar to swizzling, but they are intended for a fragment attribute such as writing depth as a fragment attribute such as portals or split-screen rendering.
Conclusion
# This is a scene rendered without a depth buffer, we can have one vertex used in multiple primitives.
In my eyes 5.2 is almost perfect, and that's what I will use for a long time.
