Reflection
- There are several built-in functions to inspect the code during compile time.
.len
on arrays return their length.$defined(<expr>)
returns true if the expression inside is defined.$alignof(<expr>)
returns alignment.$sizeof(<expr>)
returns size.$checks(<expr>)
returns true if the expression inside is valid.$qnameof(<identifier>)
to get the qualified name of the identifier, e.gstd::io::printf
$nameof(<identifier>)
to get the base name of the identifier, e.g.printf
$typeof(<expr>)
returns the type of the expression.$stringify(<expr>)
returns the expression as a string.<type>.sizeof
returns the size of a type.<type>.alignof
returns the alignment of a type.<type>.nameof
return the name of a type.
See https://c3-lang.org/reflection/ for the full details.