caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Robert Roessler <roessler@rftp.com>
To: Jacques Garrigue <garrigue@math.nagoya-u.ac.jp>
Cc: Caml-list <caml-list@inria.fr>
Subject: Re: [Caml-list] Toplevel usage of stdout and stderr
Date: Wed, 06 Apr 2005 20:40:55 -0700	[thread overview]
Message-ID: <4254ABC7.2080003@rftp.com> (raw)
In-Reply-To: <20050406.194634.00976783.garrigue@math.nagoya-u.ac.jp>

Jacques Garrigue wrote:

> From: Robert Roessler <roessler@rftp.com>
> 
>>I am close to finishing my LablGTK-based syntax-colored GUI for the 
>>toplevel... and I have noticed [the Windows version of] the ocaml 
>>toplevel seems to use both stdout and stderr for warnings and errors.
>>
>>Chapter 9 of the Objective Caml manual clearly states "results are 
>>printed on standard output, errors on standard error" and further that 
>>the Windows ocaml.exe "works exactly as under Unix".
> 
> 
> Sometimes even developers don't read the manual.
> I was convinced that in interactive mode errors go to stdout.
> I even remember some discussions about this.
> In practice it seems that errors go to stdout, but warnings go to
> stderr. Not surprising as prerr_warning takes no parameter and prints
> (almost) directly to stderr.

Actually, it is even weirder than this. :)  My favorite is

STDERR:
Characters 53-60:
Warning: this match case is unused.

STDOUT:
   match [] with
   | a :: [] -> []
   | _ :: a :: [] -> []
   | b :: [] -> []..
   | b :: [] -> [];;
     ^^^^^^^

This splitting of the same message across the two channels causes an 
ugliness - I end up having to process the stderr info (if any) before 
the stdout.  Not horrible, but I have to wait to see if there is going 
to be any stderr output.

> Sorry for this confusing situation. On Unix this is not too bad, but
> on windows the buffering can be a pain IIRC.

Good old select and low-level I/O.  Sigh.

> If you are calling ocaml as a subprocess, ocamlbrowser provides a way
> to do it, and even to kill the subprocess. Look in shell.ml. This is
> rather mixed with Tk parts. The point is that on windows Fileinput did
> not work on pipes, so an alternative system is coded using threads.

Yes, I am using a create_process - I implemented the socketpair (in 
Caml, of course) and use three of those to communicate with the 
toplevel.  I did this instead of pipes so I could use select without 
worrying about how the pipes were implemented.

The CAMLSIGPIPE thing looks like it will... work.  I would much rather 
that the kill call was supported in the Windows version of the Unix 
library - since it *could* do SIGINT.  I have already written this for 
myself, but the CAMLSIGPIPE hack has the advantage of not requiring 
the additional DLL with the kill in it.  Thanks for the tip. :)

Robert Roessler
roessler@rftp.com
http://www.rftp.com


      reply	other threads:[~2005-04-07  3:40 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-04-06  9:16 Robert Roessler
2005-04-06 10:46 ` [Caml-list] " Jacques Garrigue
2005-04-07  3:40   ` Robert Roessler [this message]

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=4254ABC7.2080003@rftp.com \
    --to=roessler@rftp.com \
    --cc=caml-list@inria.fr \
    --cc=garrigue@math.nagoya-u.ac.jp \
    /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;
as well as URLs for NNTP newsgroup(s).