let set m f a = let save = !value in try value := m; let b = f a in value := save; b with exc -> value := save; raise exc