Writing to Standard Error from gnu-prolog

From: Roger Clayton (see_at_below.for.email)
Date: 04/27/04

  • Next message: Paul Tarau: "Re: [OT] Prolog for WinCE?"
    Date: Tue, 27 Apr 2004 16:53:34 +1200
    
    

    Hi all,
    Hopefully someone can help with this - here's the problem:
    I need to write messages to the standard error stream
    rather than the standard output from a gnu-prolog program.
    (The program is a component of a compiler for a logic
    programming language).

    Although the gnu-prolog manual is excellent is most cases,
    I am having trouble finding the sequence of builtin
    predicates to make this happen. Here's a few of observations
    I have made so far.

    By consulting the interactive environment the available
    streams can be found as follows:
    ==================
    | ?- current_stream(X), current_alias(X,Y).

    X = '$stream'(0)
    Y = top_level_input ? ;

    X = '$stream'(0)
    Y = user_input ? ;

    X = '$stream'(0)
    Y = debugger_input ? ;

    X = '$stream'(1)
    Y = top_level_output ? ;

    X = '$stream'(1)
    Y = user_output ? ;

    X = '$stream'(1)
    Y = debugger_output

    yes
    ===================

    Because all the output streams are identified by '$stream'(1)
    I suspect that all these are actually the same stream and,
    moreover, none of these are identified as the standard error.

    Setting the stream via the set_output/1 predicate results
    in an existence error for anything but '$stream'(1). Creating
    a new stream via the open/3 or open/4 calls seems to result
    only in a new file being created.

    I hope someone out there has had experience with doing this
    and can steer me in the right direction. Thanks.

    Roger Clayton

    rjc4@ waikato .nz
          cs. .ac


  • Next message: Paul Tarau: "Re: [OT] Prolog for WinCE?"

    Relevant Pages

    • Re: Wrap up Text
      ... not using fflush() to ensure that the prompt will be displayed before the ... Hence to be -sure- that prompt will be visible, ... stdout is a text stream or a binary stream? ... FILE objects associated, respectively, with the standard error, ...
      (comp.lang.c)
    • Re: Handling errors in standard output statements with openmcl (learner questions)
      ... stream variable you can use to get your error output, ... its value is #<Stream for Standard Input>. ... PATHNAME: NIL. ... its value is #<Stream for Standard Error>. ...
      (comp.lang.lisp)
    • Writing to standard error from gnu-prolog
      ... I need to report a message to the standard error stream ... rather than the standard output in a gnu-prolog program. ... builtin predicates to make this happen. ...
      (comp.lang.prolog)
    • Re: coderwiki.com is starting and needs you!
      ... But printf doesn't output to the screen or terminal. ... writes its data on the standard output stream. ... can only handle a few abstract terms until it short circuits. ...
      (comp.lang.c)
    • Re: scanf() quesion?
      ... this is because the standard output ... stream is typically line-buffered. ... characters are intended to ... when a buffer is filled. ...
      (comp.lang.c)