Skip to content

Commit

Permalink
Stdlib: added Printf.ikbprintf, Printf.ibprintf
Browse files Browse the repository at this point in the history
  • Loading branch information
muskangarg21 committed Mar 15, 2020
1 parent 7fd5dd9 commit 5b0c9d7
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 0 deletions.
3 changes: 3 additions & 0 deletions Changes
Expand Up @@ -103,6 +103,9 @@ Working version
for formatter geometry changes that are robust to new geometry fields.
(Gabriel Scherer, review by Josh Berdine and ???)

- #7110: Added Printf.ikbprintf and Printf.ibprintf
(Muskan Garg, review by Gabriel Scherer and Florian Angeletti)

### Other libraries:

- #9106: Register printer for Unix_error in win32unix, as in unix.
Expand Down
3 changes: 3 additions & 0 deletions stdlib/printf.ml
Expand Up @@ -22,10 +22,13 @@ let kbprintf k b (Format (fmt, _)) =
make_printf (fun acc -> bufput_acc b acc; k b) End_of_acc fmt
let ikfprintf k oc (Format (fmt, _)) =
make_iprintf k oc fmt
let ikbprintf k bc (Format (fmt, _)) =
make_iprintf k bc fmt

let fprintf oc fmt = kfprintf ignore oc fmt
let bprintf b fmt = kbprintf ignore b fmt
let ifprintf oc fmt = ikfprintf ignore oc fmt
let ibprintf b fmt = ikbprintf ignore b fmt
let printf fmt = fprintf stdout fmt
let eprintf fmt = fprintf stderr fmt

Expand Down
12 changes: 12 additions & 0 deletions stdlib/printf.mli
Expand Up @@ -147,6 +147,12 @@ val ifprintf : 'b -> ('a, 'b, 'c, unit) format4 -> 'a
@since 3.10.0
*)

val ibprintf : Buffer.t -> ('a, Buffer.t, 'c, unit) format4 -> 'a
(** Same as {!Printf.bprintf}, but does not print anything.
Useful to ignore some material when conditionally printing.
@since 4.11.0
*)

(** Formatted output functions with continuations. *)

val kfprintf : (out_channel -> 'd) -> out_channel ->
Expand Down Expand Up @@ -175,6 +181,12 @@ val kbprintf : (Buffer.t -> 'd) -> Buffer.t ->
@since 3.10.0
*)

val ikbprintf : (Buffer.t -> 'd) -> Buffer.t -> ('a, Buffer.t, 'c, 'd) format4 -> 'a
(** Same as [kbprintf] above, but does not print anything.
Useful to ignore some material when conditionally printing.
@since 4.11.0
*)

(** Deprecated *)

val kprintf : (string -> 'b) -> ('a, unit, string, 'b) format4 -> 'a
Expand Down

0 comments on commit 5b0c9d7

Please sign in to comment.