Re: streams

Vic Bancroft <[email protected]>
Newsgroups gmane.comp.gnu.prolog.general
Organization netizens
Message-ID <[email protected]>
Cliff Bender wrote:

>I'd like some help trying to understand the use of streams. 
>
Hurrms, not sure what is broken w/ your example, however, I tend to use 
the format construct.

    $ gprolog
    GNU Prolog 1.2.18
    By Daniel Diaz
    Copyright (C) 1999-2004 Daniel Diaz
    | ?- assertz(p(1)), assertz(p(2)).

    yes
    | ?- open('out.log', write, H), (p(X), format(H, "p(~w) ~n", [X]),
    fail; close(H)), !.

    H = '$stream'(2)

    (1 ms) yes
    | ?- system('cat out.log').
    p(1)
    p(2)

    (1 ms) yes

This explicit indication of the target stream is useful in context where 
there is more than one and it also gives you more control over what is 
sent to the stream . . .

more,
l8r,
v

-- 
"The future is here. It's just not evenly distributed yet."
 -- William Gibson, quoted by Whitfield Diffie
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.