Mojo module
type_info
Provides type and function name introspection utilities.
This module provides compile-time introspection of type and function names:
get_type_name[T]()- returns the name of a typeget_function_name[func]()- returns the source name of a functionget_linkage_name[func]()- returns the symbol/linkage name of a function
Example:
from reflection import get_type_name, get_function_name
struct Point:
var x: Int
var y: Float64
fn my_function():
pass
fn main():
print(get_type_name[Point]()) # "Point"
print(get_function_name[my_function]()) # "my_function"Functionsβ
- β
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.
Was this page helpful?
Thank you! We'll create more content like this.
Thank you for helping us improve!