OxL Reference

fn reflect

reflect(T); expanded by the compiler, never called at run time.

Example:

oxl✓ checked in CI
use std.reflect { reflect }

data Row {
  id: i64
  name: str
}

fn describe(r: &Row) -> String {
  var out = String.new()
  inline for f in reflect(Row).fields {
    out.push("{f.name}={r.[f]};")
  }
  out
}

fn main() io {
  print(describe(&Row(id: 7, name: "ann")))
}
Output
id=7;name=ann;
@intrinsic("reflect") pub(api) comptime fn reflect(T: i32) -> TypeInfo

Complexity. evaluated at compile time; no run-time cost.

Since. 1.0.0-beta

Parameters

NameType
Ti32

Returns

TypeInfo

Effects

none declared (pure unless the body says otherwise)

Defined in: std/reflect/reflect.oxl:202

See also