debug :: import "@std/debug" meta :: import "@std/meta" Numbers :: struct { i8, i16, i32 } Row :: struct { value i32 } format func() []u8 { return "tuple={d}/{s}, limits={d}/{d}" } sum func($T type, value T) i32 { total i32 := 0 match typeinfo!(T) { .record |record|: inline for record.fields |field| { total += i32(field!(value, field.name)) } else: compile_error!("sum requires a record") } return total } static_control func($T type, value T) i32 { total i32 := 0 match typeinfo!(T) { .record |record|: inline for record.fields |field| { { if field.index == 1 { continue } total += i32(field!(value, field.name)) match typeinfo!(field.type) { .integer: { if field.index == 2 { break } } else: _ = 0 } } total += 100 } else: compile_error!("static_control requires a record") } return total } row_value func(row Row) i32 { return row.value } static_aggregates func() i32 { total i32 := 0 inline for {Row {value = 2}, Row {value = 40}} |row| { total += row_value(row) } return total } main func() i32 { numbers Numbers := Numbers {1, 2, 39} singleton :: {42,} empty :: {} block_value :: { yield 42 } _ = empty if singleton.0 != block_value { return 2 } if sum(Numbers, numbers) != 42 { return 1 } if static_control(Numbers, numbers) != 140 { return 3 } if static_aggregates() != 42 { return 4 } field!(&numbers, "2") += 1 debug.print("hello!\n", {}) debug.print(format(), { numbers.2, "bro", minval!(i64), maxval!(u64), }) return 0 }