From: Alain Frisch <frisch@clipper.ens.fr>
To: caml-list@inria.fr
Subject: $0.02 suggestion for the Printf module
Date: Mon, 18 Oct 1999 18:15:06 +0200 (MET DST) [thread overview]
Message-ID: <Pine.GSO.4.04.9910181814320.22844-100000@clipper> (raw)
As I didn't find a powerful enough preprocessor, and I find perl ugly,
I try to use OCaml to generate text file (html, latex, etc ...).
So I have a global mutable variable containing a printing function.
In different situation, this function write directly to a file or add the
text to a buffer (to preprocess it before sending it), or filter the text
through another function, etc ...
I want to use the printf formating functions. With the current Printf
module, I have to use create a buffer, bprintf in the buffer, extract the
content of the buffer, print this string with my printing function.
As I want to do it often, it would be useful to have a function :
gen_printf: (string -> ()) -> ('a, Buffer.t, unit) format -> 'a
[or for performance (string -> ()) -> (char -> ()) -> ('a, ... ]
taking as its first argument a 'printing function'
(so printf == gen_printf print_string; etc ...)
As far as I know it is impossible to implement it in the core langage,
so the only solution for the moment is to hack with the source code of
Printf (it takes 20 seconds to implement gen_printf from printf).
I think it would be a good idea to add such a function in the Printf
module.
Btw, I don't understand the tests performed on the format 'string' in
Printf functions : aren't they already done by the compiler during the
typing ?
--
Alain Frisch
next reply other threads:[~1999-10-19 17:24 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
1999-10-18 16:15 Alain Frisch [this message]
1999-10-19 19:15 ` William Chesters
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=Pine.GSO.4.04.9910181814320.22844-100000@clipper \
--to=frisch@clipper.ens.fr \
--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