Read term from a pipe?

tcklnbrg at at ingenuity-sw.com
Fri Jun 5 09:46:21 AEST 1998


1) pipes:  The ISO Prolog compliant predicate, "open(+SrcDest, +Mode,
-Stream, +Options)", allows SrcDest to be
a term of the form, "pipe(Command)".  This allows you to pipe a command
to the OS and read the resulting
output.  Does Mercury support anything like this, ie., reading the
result of a command that was piped
to the OS or shell?

I have been using this to read in a term with the following code in
SWI-Prolog:
... open(pipe(Command), read, X,[eof_action(eof_code)]),
read(X, T), close(X)...

where X is the stream identifier and T is the term that is read in.

2)reading terms:  I can successfully read in a term typed in at the
keyboard
using the term_io__read_term pred., and I note that the source for
io__read
calls term_io__read_term.  However, I can't figure out how to code
io__read(io__read_result(T), io__state, io_state).  What does the 
compiler want for the "io__read_result(T)" arg?.


I need to convert the SWI code to Mercury.  Suggestions?


Thanks for any advice,

Ann Tecklenburg



More information about the users mailing list