Repository navigation
Normalized Lua Functions
I am happy to announce release 4 of std.normalize.
std.normalize's home page is at https://lua-stdlib.github.io/normalize
Noteworthy changes in release 4 (2026-10-22) [stable]
New features
-
New
getmetafieldreturns a named field of the metatable of an
object, ornil, without the error that(getmetatable(x) or {})[n]raises when__metatablemakesgetmetatablereturn
something that is not a table. -
New
callablereturns an object that can be called, a function or a
functor, as it is, ornil; andiscallablesays whether it can.
They are in the core functions thatrequire 'std.normalize' {}
gives a module. -
The functions that typecheck, std.strict and optparse would
otherwise copy,callable,iscallable,getfenv,getmetafield,
getmetamethod,len,pack,pairs,rawlen,setfenvand
tointeger, are instd.normalize._core, which requires nothing,
so that they can vendor a copy of that one file.
Incompatible changes
setfenv(0, env)raises an error in every Lua. Lua 5.2 and later
have no global environment to replace, where Lua 5.1 did, so it used
to change the globals in 5.1 and silently do nothing in the others.
getfenv(0)returns_Gin every Lua.
Bug fixes
-
The documentation of
lenno longer says that it uses a
__tostringmetamethod, which it has not done since release 2.0.4.
(It returns the length of the object, ignoring that metamethod.) -
loadaccepts a string-like object, one with a__tostring
metamethod, as the chunk or the chunk name again, as it did before
its arguments were checked with typecheck. -
callable,getmetamethodandunwrapno longer raise an error
for an object whose__metatablefield is not a table, such as
true, when asked whether it can be called. -
In Lua 5.1,
getfenvandsetfenvfind the function at a stack
level and usedebug.getfenvanddebug.setfenvon it, instead of
a globalgetfenvandsetfenvthat the host environment supplies,
which inside Specl's sandbox are std.normalize's own. The global
ones are used only when there are nodebugversions.
Install it with LuaRocks, using:
luarocks install std.normalize 4