let dynamic_let (x, v) f a = let saved = !x in try let result = (x := v; f a) in x := saved; result with | exc -> x := saved; raise exc