Mailing list for all users of the OCaml language and system.
 help / color / mirror / Atom feed
From: "Adam P. Jenkins" <ajenkins@cs.umass.edu>
To: caml-list@inria.fr
Subject: print and output
Date: Wed, 2 Jul 1997 14:43:10 -0400	[thread overview]
Message-ID: <199707021843.OAA00394@dwarin.oit.umass.edu> (raw)
In-Reply-To: <v01530501afde7af99a9d@[129.88.38.40]>

Michel Levy writes:
 > 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
 > val read_int : unit -> int
 >         Flush standart output then ...
 > 
 > Quand j'ecris le "programme" suivant :
 >         output_string ">>"; read_int ();;
 > l'impression a lieu avant la lecture, ce qui est heureux.
 > 
 > Pourquoi cette diffence, car je pensais que :
 >         print_string = output_string stdout
 > 
 > Hi
 > 
 > When I write (in OCAML) the following program :
 >         print_string ">>"; read_int ();;
 > the reading takes place before the printing, what surprises me.
 > 
 > On the contrary, when I write :
 >         output_string ">>"; read_int ();;
 > the printing takes place before the reading, what is better.
 > 
 > Why this difference, whereas I thought that :
 >         print_string = output_string stdout
 > 
 > 
 > Michel Levy
 > D106 - Laboratoire LSR
 > B.P.72 - 38402 SAINT MARTIN D'HERES CEDEX - France
 > Tel : 0476827246
 > e.mail : Michel.Levy@imag.fr
 > 
 > 
 > 
 > 


That is kind of strange, since print_string is implemented with
output_string.  Maybe it just had to do with the order in which you
executed the commands, i.e. when the stdout buffer became full.

> cd /usr/local/lib/ocaml
> grep print_string pervasives.ml
let print_string s = output_string stdout s

To make the printing happen first in either case, you can add 
"flush stdout;".

	print_string ">>"; flush stdout; read_int ();;

Adam





  reply	other threads:[~1997-07-03  7:43 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1997-07-01  9:43 Michel Levy
1997-07-02 18:43 ` Adam P. Jenkins [this message]
1997-07-03  7:54 ` Pierre Weis

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=199707021843.OAA00394@dwarin.oit.umass.edu \
    --to=ajenkins@cs.umass.edu \
    --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