Doc needs help
"Initially, these are bound to the same stream as user_input and user_error."
Should be "...and user_output".
format("Hello")
prints to stdout, not stderr....
How to print to stderr
To print to stderr, just call
format(user_error,"Hello world!",[]).
In interactive mode, printing to stderr is not distinguishable from printing to stdout (both outputs go to the terminal).
However at the level of the shell, if we redirects stderr to /dev/null, nothing is shown (the swipl
command below just runs a format/3 goal and then halts):
$ swipl -g 'format(user_error,"Hello world!~n",[]).' -t halt 2>/dev/null
On the other hand, this command properly emits text to stderr:
$ swipl -g 'format(user_error,"Hello world!~n",[]).' -t halt Hello world!
Alias
Apparently user_ouput
and user
are aliases. One finds a mention of user
in the documentation from time to time. Maybe it's an old alias?
?- write(user_output, "Hello"). Hello true. ?- write(user, "Hello"). Hello true.