# A ternary choosing while compiling checks each branch with what its # condition says, and a note said in one case says which. A `match const` of # values chooses by a constant, its patterns of the constant's type, and an # instance none fits, without `else`, is an error. Each instance checks the # branch it takes, so `&` of what a `*T` points at writes nothing. type addref = M ? &mut T : &T; type castref = match const T { reference => T, pointer => addref, else => addref }; pub def tern(ptr: T): castref where T: pointer { return T::mutable ? &mut ptr[0] : 5; } def pats(): u8 { return match const N { 4 => 1, "a" => 2, else => 3 }; } def typed(): u8 { return match const T { 4 => 1, else => 2 }; } def runtime(x: u64): u8 { return match const x { 1 => 1, else => 2 }; } def mixed(): u8 { val v := M ? 1 as u8 : "a"; return v; } def none(): u8 { return match const N { 1 => 1, 2 => 2 }; } def through(ptr: T): castref where T: pointer { return T::mutable ? &mut ptr[0] : &ptr[0]; } def main(): void { var x: i32 = 1; through(&x as *i32) = 3; val n := none::<3>(); }