fn receive (receiver) -> { print! ("receiving in", self (), "with msgs", msgs()) if empty? (msgs ()) then {yield! (); receive (receiver)} else do msgs () > first > receiver } fn foo? (val) -> receive (fn (msg) -> match report!("scrutinee is", msg) with { (:report) -> { print! ("LUDUS SAYS ==> value is {val}") flush! () foo? (val) } (:set, x) -> { print! ("LUDUS SAYS ==> foo! was {val}, now is {x}") flush! () foo? (x) } (:get, pid) -> { print! ("LUDUS SAYS ==> value is {val}") send (pid, (:response, val)) flush! () foo? (val) } x -> print! ("LUDUS SAYS ==> no match, got {x}") }) let foo = spawn! (fn () -> foo? (42)) print! (foo) send (foo, (:set, 23)) yield! () send (foo, (:get, self ())) yield! () fn id (x) -> x receive(id)