@module ref

ref value = Ref (spawn [ ! => loop value ])

loop value = receive [
  .set new-value => loop new-value
  p, id, .get => { send p (id, value); loop value }
]

@object Ref pid [
  set val = .set val > send pid
  get! = .get > send-wait pid
]
