* Pervasives 'general output functions'
@ 2004-10-29 9:40 Diego Olivier Fernandez Pons
2004-10-29 10:12 ` [Caml-list] " Nicolas Cannasse
0 siblings, 1 reply; 2+ messages in thread
From: Diego Olivier Fernandez Pons @ 2004-10-29 9:40 UTC (permalink / raw)
To: caml-list
Bonjour,
I would like a Caml program to output some information to an output
channel and according to my needs this channel be redirected to
- a (human readable) file
- the standard output
- a black hole
The "general output functions" section of Pervasives seem to be what I
need but it hasn't the same signature than "Output functions on
standard output"
print_char -> output_char
print_string -> output_string
print_int -> ?
print_float -> ?
print_endline -> ?
print_newline -> ?
I suspect I could just compose with string_of_X functions to obtain
the same result. There is also an awful [fprintf] function inherided
from C but I am still trying to understand the doc (never understood
C's either).
Why haven't the equivalent functions been added to the standard lib to
allow a drop in replacement ?
Diego Olivier
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [Caml-list] Pervasives 'general output functions'
2004-10-29 9:40 Pervasives 'general output functions' Diego Olivier Fernandez Pons
@ 2004-10-29 10:12 ` Nicolas Cannasse
0 siblings, 0 replies; 2+ messages in thread
From: Nicolas Cannasse @ 2004-10-29 10:12 UTC (permalink / raw)
To: Diego Olivier Fernandez Pons, caml-list
> Bonjour,
>
> I would like a Caml program to output some information to an output
> channel and according to my needs this channel be redirected to
> - a (human readable) file
> - the standard output
> - a black hole
>
> The "general output functions" section of Pervasives seem to be what I
> need but it hasn't the same signature than "Output functions on
> standard output"
Generic IO from ExtLib are dealing with this problem, and have a printf
functionnality.
They also have useful functions such as write_i16 / write_ui32 .... (in low
and big endian) when dealing with C binary files.
> I suspect I could just compose with string_of_X functions to obtain
> the same result. There is also an awful [fprintf] function inherided
> from C but I am still trying to understand the doc (never understood
> C's either).
printf "%d %f %s %c" 33 1.234 "hello" 'x'
> Why haven't the equivalent functions been added to the standard lib to
> allow a drop in replacement ?
Maybe because printf allows you to specify precision for int/floats as well
as newlines ?
Nicolas
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2004-10-29 10:13 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-10-29 9:40 Pervasives 'general output functions' Diego Olivier Fernandez Pons
2004-10-29 10:12 ` [Caml-list] " Nicolas Cannasse
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox