AcediaDocumentation

debug.getprotos

Lists handles for a Lua function's immediate nested prototypes.

These are inactive inspection handles, not executable closures. Only immediate children are returned; inspect a child again to descend further.

debug.getprotos(subject: function | number): {function}

Parameters

ParameterTypeDescription
subjectfunction | numberLua function or reachable stack level. C functions are rejected by prototype readers.

Example

local function outer()
    local function inner() return 1 end
    return inner
end
for _, handle in ipairs(debug.getprotos(outer)) do
    print(debug.getinfo(handle).what)
end

Example output

Lua

Errors: Invalid stack levels or C-function subjects raise errors.

Aliases: getprotos.

On this page