let pop s = 
  match !s with
    v::tl -> s := tl; v
  | _ -> failwith "pop: empty stack"