Quirrel4.41.0

debug.get_function_info_table

Defined in module "debug"
from "debug" import get_function_info_table
get_function_info_table(func: function): table|null

Returns meta information about a function as table

Parameters

funcfunctionthe function to inspect

Return value

A table with these keys:

Errors

func must already be a closure or a native closure; passing anything else fails the parameter type check before this function runs.

Notes

pure is true either because the function carries the [pure] attribute, or because the compiler proved the body has no side effect on its own, without any attribute written. fastcall is a native-only trait; a script closure never reports it.

A native bound through a type mask instead of a declaration string has no real parameter names, so argNames is filled with placeholders arg1, arg2, and so on. Most methods on the built-in types (array, string, ...) are bound this way, since they typecheck arguments with a mask rather than a parsed decl string.

When SQ_STORE_DOC_OBJECTS is disabled, native declaration text is not retained. Native functions then use the type-mask fallback, so declaration-only parameter names and the declared return type are not available.

Example

examples/debug/get_function_info_table.nut
from "debug" import get_function_info_table

function add(a, b = 5) { return a + b }
let t = get_function_info_table(add)
println($"{t.functionName} native={t.native} requiredArgs={t.requiredArgs}")
println("t.argNames =", ", ".join(t.argNames))

// no attribute was written, but the compiler proved the body has no side effect
println($"pure={t.pure}")

// array.insert is bound with a type mask, not a decl string, so it has no real
// parameter names
println("get_function_info_table([].insert).argNames =", ", ".join(get_function_info_table([].insert).argNames))
Output:
add native=false requiredArgs=1
t.argNames = a, b
pure=true
get_function_info_table([].insert).argNames = arg1, arg2

See also

get_function_decl_stringReturns a function declaration string
type_mask_to_stringConvert type mask to human-readable string
docReturns a documentation string for a function, class, or instance
debugmodule index