From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from majordomo@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id BAA00260; Thu, 7 Nov 2002 01:32:08 +0100 (MET) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id BAA00276 for ; Thu, 7 Nov 2002 01:32:07 +0100 (MET) X-SPAM-Warning: Sending machine is listed in blackholes.five-ten-sg.com Received: from athlon.baretta.com ([62.211.4.177]) by concorde.inria.fr (8.11.1/8.11.1) with ESMTP id gA70W6524745 for ; Thu, 7 Nov 2002 01:32:06 +0100 (MET) Received: from baretta.com (localhost.localdomain [127.0.0.1]) by athlon.baretta.com (Postfix) with ESMTP id 7C8F427252 for ; Thu, 7 Nov 2002 01:31:50 +0100 (CET) Message-ID: <3DC9B476.1010009@baretta.com> Date: Thu, 07 Nov 2002 01:31:50 +0100 From: Alessandro Baretta Organization: Baretta srl -- www.baretta.com User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.1) Gecko/20020826 X-Accept-Language: it, en MIME-Version: 1.0 To: ocaml Subject: Re: [Caml-list] Format question References: <200211070009.TAA00453@apakabar.cc.columbia.edu> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk 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