debug.getprotos
Lists a function's child prototypes.
Syntax
Signature
debug.getprotos(FunctionOrLevel: function | number, CreateClosures: boolean?) -> tableAliases
This function has no aliases.
Parameters
| Parameter | Type | Description |
|---|---|---|
FunctionOrLevel | function | number | Luau closure or positive stack level. |
CreateClosures | boolean? | Return new child closures instead of prototype pointers. Defaults to false. |
Returns
| Type | Description |
|---|---|
table | One-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