Commits

camlspotter  committed ed5815b Merge

merge

  • Participants
  • Parent commits d2b744d, be2b91a

Comments (0)

Files changed (3)

 - Older functional compositions (^.) (&.) (@@) are removed.
 - Added Result.
 - Added Option.catch and Result.catch (and catch_exn)
+- Added Base.with_final
 
 2.1.0
 ------------
 exception Finally of exn * exn
 ;;
 
+(* CR jfuruse: looks lousy... *)
 let protect ~f v ~(finally : 'a -> unit) =
   let res =
     try f v

File lib/base.mli

 (** [true] at success *)
 
 val with_final : 'a -> ('a -> 'b) -> ('a -> unit) -> 'b
+(** [with_final v f final] returns [f v] but runs [final v]
+    before returning the result. 
+    
+    Exception handling:
+    [final v] is called even if [f v] raises an exception.
+
+    If [final v] raises an exception [e], [with_final v f final] does:
+    - Re-throws [e] when [f v] returns normally.
+    - Ignore [e] and re-throws [e'] when [f v] raises an exception [e'].
+
+*)
 
 (** {6 Imperative operations } *)