Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Re: [Caml-list] kprintf with user formatters #2942

Closed
vicuna opened this issue Jul 15, 2004 · 1 comment
Closed

Re: [Caml-list] kprintf with user formatters #2942

vicuna opened this issue Jul 15, 2004 · 1 comment

Comments

@vicuna
Copy link

vicuna commented Jul 15, 2004

Original bug ID: 2942
Reporter: administrator
Status: closed (set by @damiendoligez on 2012-01-30T14:15:53Z)
Resolution: fixed
Priority: normal
Severity: feature
Fixed in version: 3.10.0
Category: ~DO NOT USE (was: OCaml general)

Bug description

On Thu, 15 Jul 2004, Damien wrote:

I had the same problem a month ago,
I ended with the following ugly function:

let log b fmt =
if b then Printf.printf fmt
else
let rec f x = Obj.magic f in
f fmt
(* val f: bool -> ('a, out_channel, unit) format -> 'a *)

(I think this is safe since f just eats its arguments,
and gets typed with "-rectypes" : ('b->'a) as 'a)

maybe a function "zprintf" could be added to Printf and Format to do
this job ?

Thanks for the hint, this works for me! I also think that there should be
some kind of "zprintf"-function in the standard library. Forcing people
to use "-rectypes" or "Obj.magic" is evil.

Regards,
Markus

--
Markus Mottl http://www.oefai.at/~markus markus@oefai.at

@vicuna
Copy link
Author

vicuna commented Jan 30, 2012

Comment author: @damiendoligez

This is available since 3.10.0 as Printf.ifprintf (typed like fprintf but ignores all its arguments).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant