// Labelled and unlabelled arguments mix (ADR 0061): labels are declared // at the definition and apply by name in any order; unlabelled ones fill // the unlabelled parameters in order — so `use` works with labels. import std/io fn guard :: ~when: Bool ~value: String otherwise: fn() -> String / -> String / { if when { value } else { otherwise () } } fn show_pair :: a: Int ~b: String ~c: String -> String { "{a}:{b}:{c}" } pub fn main :: -> () / { // The callback fills `otherwise`, the unlabelled parameter left. let result = { use <- guard ~when: False ~value: "taken" "from the callback" } io.println result let taken = { use <- guard ~when: True ~value: "taken" "from the callback" } io.println taken // Mixed calls, both orders. io.println (show_pair 1 ~c: "see" ~b: "bee") io.println (show_pair ~b: "bee" 1 ~c: "see") } //> from the callback //> taken //> 1:bee:see //> 1:bee:see