More concretely: I want to implement a
dprintf function that works like this
let dprintf fmt = let flag = true in if flag then Printf.eprintf fmt else ???
What do I write instead of
??? to make
dprintf a no-op if
flag = false? I tried
Printf.ifprintf stderr fmt which sort of works? However godbolt shows that if ifprintf is far from being zero-cost, which is unacceptable in a high-performance program I’m writing. What I want is that if
flag = false then
dprintf <whatever> is
(). I guess this would require a way to write variadic functions (much like
*printf). Is there any way to do this?