Skip to content

[ANN] std.normalize v4 released

Latest

Choose a tag to compare

@gvvaughan gvvaughan released this 23 Oct 00:31
· 3 commits to master since this release

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 getmetafield returns a named field of the metatable of an
    object, or nil, without the error that (getmetatable(x) or {})[n] raises when __metatable makes getmetatable return
    something that is not a table.

  • New callable returns an object that can be called, a function or a
    functor, as it is, or nil; and iscallable says whether it can.
    They are in the core functions that require '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, setfenv and
    tointeger, are in std.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 _G in every Lua.

Bug fixes

  • The documentation of len no longer says that it uses a
    __tostring metamethod, which it has not done since release 2.0.4.
    (It returns the length of the object, ignoring that metamethod.)

  • load accepts 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, getmetamethod and unwrap no longer raise an error
    for an object whose __metatable field is not a table, such as
    true, when asked whether it can be called.

  • In Lua 5.1, getfenv and setfenv find the function at a stack
    level and use debug.getfenv and debug.setfenv on it, instead of
    a global getfenv and setfenv that the host environment supplies,
    which inside Specl's sandbox are std.normalize's own. The global
    ones are used only when there are no debug versions.

Install it with LuaRocks, using:

luarocks install std.normalize 4