debug.getprotos

Lists a function's child prototypes.

Syntax

Signature
debug.getprotos(FunctionOrLevel: function | number, CreateClosures: boolean?) -> table

Aliases

This function has no aliases.

Parameters

ParameterTypeDescription
FunctionOrLevelfunction | numberLuau closure or positive stack level.
CreateClosuresboolean?Return new child closures instead of prototype pointers. Defaults to false.

Returns

TypeDescription
tableOne-based list of prototype pointers or newly created closures.

Notes

By default the entries are lightuserdata prototype pointers. CreateClosures returns newly allocated closures instead. Those closures do not recover captured upvalue values.

Example

Luau
local function Parent()
    return function() return 42 end
end
for Index, Prototype in debug.getprotos(Parent) do
    print(Index, Prototype)
end