IMPORTANT: To view this page as Markdown, append `.md` to the URL (e.g. /docs/manual/basics.md). For the complete Mojo documentation index, see llms.txt.
Skip to main content
Version: 1.0
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 (replaces get_type_name)
  • reflect[T]().base_name() - returns the unqualified name of a type's base type (replaces get_base_type_name)
  • get_function_name[func]() - returns the source name of a function
  • get_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