From: Alessandro Baretta <alex@baretta.com>
To: ocaml <caml-list@inria.fr>
Subject: Re: [Caml-list] Format question
Date: Thu, 07 Nov 2002 01:31:50 +0100 [thread overview]
Message-ID: <3DC9B476.1010009@baretta.com> (raw)
In-Reply-To: <200211070009.TAA00453@apakabar.cc.columbia.edu>
Oleg wrote:
> Oleg wrote:
>
>
>>Is it possible to define a printf that automatically flushes stdout?
>>
>
>
> I figured it out:
>
> let my_printf (x : ('a, out_channel, unit) format) =
> let tmp = Printf.printf x in flush stdout; tmp;;
>
> Oleg
I don't think this does what you want it to. This functions
starts to parse the format string and prints it until the
first conversion specifier, where it stops. Then it flushes
stdout and returns a closure which will perform the
specified conversion. When the function is then invoked on
the actual parameters of the conversion, stdout is no longer
flushed.
Basically, this works only if what you're printing is just
constant strings. But then you're probably better off with
let my_printf x = print_string x; flush stdout
Alex
-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
next prev parent reply other threads:[~2002-11-07 0:32 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2002-11-07 0:09 Oleg
2002-11-07 0:31 ` Alessandro Baretta [this message]
2002-11-07 0:46 ` Gerd Stolpmann
-- strict thread matches above, loose matches on Subject: below --
2002-11-06 22:49 Oleg
2002-11-06 23:46 ` David Brown
2002-11-20 0:29 ` David Frese
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=3DC9B476.1010009@baretta.com \
--to=alex@baretta.com \
--cc=caml-list@inria.fr \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox