Functions Metadata

The metadata of a function means all relevant information related to a function’s definition including:

  1. Its callable name

  2. Its access mode (public or private)

  3. Its parameter names (if any)

  4. Its purpose, in the form of doc-comments

  5. Usage notes, warnings, examples etc., in the form of doc-comments

A function’s signature encapsulates the first three pieces of information in a single concise line of definition:

[private] name (param 1, param 2,, param n )

Get Functions Metadata

The built-in function get_fn_metadata_list returns an array of object maps, each containing the metadata of one script-defined function in scope.

get_fn_metadata_list has a few versions taking different parameters:

SignatureDescription
get_fn_metadata_list()returns an array for all script-defined functions
get_fn_metadata_list(name)returns an array containing all script-defined functions matching a specified name
get_fn_metadata_list(name, params)returns an array containing all script-defined functions matching a specified name and accepting the specified number of parameters

The return value is an array of object maps containing the following fields.

FieldTypeOptional?Description
namespacestringyesthe module namespace if the function is defined within a module
accessstringno"public" if the function is public,
"private" if it is private
namestringnofunction name
paramsarray of stringsnoparameter names
this_typestringyesrestrict the type of this if the function is a method
is_anonymousboolnois this function an anonymous function?
commentsarray of stringsyesdoc-comments, if any, one per line