[
Home
]
[ Index:
by date
|
by threads
]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
| Date: | -- (:) |
| From: | Alessandro Baretta <alex@b...> |
| Subject: | Re: [Caml-list] Format question |
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