For the complete Mojo documentation index, see llms.txt. Markdown versions of all pages are available by appending .md to any URL (e.g. /docs/manual/basics.md).
type_info
Provides type and function name introspection utilities.
This module provides compile-time introspection of type and function names.
The type name APIs (get_type_name, get_base_type_name) are deprecated; use
the methods on Reflected[T] (obtained via reflect[T]()) instead:
reflect[T]().name()- returns the name of a type (replacesget_type_name)reflect[T]().base_name()- returns the unqualified name of a type's base type (replacesget_base_type_name)get_function_name[func]()- returns the source name of a functionget_linkage_name[func]()- returns the symbol/linkage name of a function
Example:
from std.reflection import reflect, get_function_name
struct Point:
var x: Int
var y: Float64
def my_function():
pass
def main():
print(reflect[Point]().name()) # "Point"
print(get_function_name[my_function]()) # "my_function"
Functions
-
get_base_type_name: Returns the name of the base type of a parameterized type. -
get_function_name: Returnsfunc's name as declared in the source code. -
get_linkage_name: Returnsfunc's symbol name. -
get_type_name: Returns the struct name of the given type parameter.