From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from weis@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id JAA21571 for caml-redistribution; Thu, 3 Jul 1997 09:54:47 +0200 (MET DST) 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 JAA21561 for ; Thu, 3 Jul 1997 09:54:32 +0200 (MET DST) Received: from pauillac.inria.fr (pauillac.inria.fr [128.93.11.35]) by concorde.inria.fr (8.8.5/8.7.3) with ESMTP id JAA25648; Thu, 3 Jul 1997 09:54:31 +0200 (MET DST) Received: (from weis@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id JAA21557; Thu, 3 Jul 1997 09:54:30 +0200 (MET DST) From: Pierre Weis Message-Id: <199707030754.JAA21557@pauillac.inria.fr> Subject: Re: print and output In-Reply-To: from Michel Levy at "Jul 1, 97 10:43:09 am" To: Michel.Levy@imag.fr (Michel Levy) Date: Thu, 3 Jul 1997 09:54:29 +0200 (MET DST) Cc: caml-list@inria.fr MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: weis Bonjour, > Quand j'ecris (en Ocaml) le "programme" suivant : > print_string ">>"; read_int ();; > l'impression a lieu apres la lecture, ce qui me surprend, car il est dit J'ai essaye' vos diffe'rentes versions, et toutes marchaient comme vous vous y attendez. Je pense que votre proble`me vient peut-e^tre du fait que vous utilisez la bibliothe`que Format. En ce cas, il y a un retard a` l'impression car il faut attendre le mate'riel d'impression pour pouvoir imprimer correctement. Si vous avez effectivement fait open Format, il vous faut vider la queue d'impression avec print_flush. E'crivez: print_string ">>"; print_flush (); read_int ();; Ou bien appelez directement la primitive de base: Pervasives.print_string ">>"; read_int ();; > Hi > > When I write (in OCAML) the following program : > print_string ">>"; read_int ();; > the reading takes place before the printing, what surprises me. I tried your programs and they work fine, as you expect them to work. My guess is that you don't use the basic print_string function, but the one of the Format library module. That may be the case if you have already open the Format module. In that case, you need to flush the formatting queue with print_flush. You may write print_string ">>"; print_flush (); read_int ();; Alternatively, you may directly call the standard primitive with: Pervasives.print_string ">>"; read_int ();; Pierre Weis INRIA, Projet Cristal, Pierre.Weis@inria.fr, http://pauillac.inria.fr/~weis/