From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: weis Received: (from weis@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id TAA09540 for caml-redistribution; Tue, 19 Oct 1999 19:24:42 +0200 (MET DST) Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id SAA02953 for ; Mon, 18 Oct 1999 18:15:09 +0200 (MET DST) Received: from nef.ens.fr (nef.ens.fr [129.199.96.12]) by nez-perce.inria.fr (8.8.7/8.8.7) with ESMTP id SAA08609 for ; Mon, 18 Oct 1999 18:15:08 +0200 (MET DST) Received: from clipper.ens.fr (clipper-gw.ens.fr [129.199.1.22]) by nef.ens.fr (8.9.3/beig-1.0) with ESMTP id SAA20444 for ; Mon, 18 Oct 1999 18:15:06 +0200 (MET DST) Received: from localhost (frisch@localhost) by clipper.ens.fr (8.9.2/jb-1.1) id SAA24298 for ; Mon, 18 Oct 1999 18:15:06 +0200 (MET DST) Date: Mon, 18 Oct 1999 18:15:06 +0200 (MET DST) From: Alain Frisch X-Sender: frisch@clipper To: caml-list@inria.fr Subject: $0.02 suggestion for the Printf module Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: weis 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