Hi folks,
Well, I know these statements are outdated, but please, consider this
code:
%-----------------
go :-
tell('aaa'), writeq('First line of ''aaa'''), write('.'),nl,
tell('bbb'), writeq('First line of ''bbb'''), write('.'),nl,nl,
tell(user), writeq('This goes on the screen'),write('.'),nl,
tell('aaa'), writeq('Second line of ''aaa'''), write('.'),nl,nl,
told.
goread :-
see('aaa'), read(X1),
see('bbb'), read(X2),
see(user), write('Type something, end with dot: '), read(X3),
see('aaa'), read(X4),
seen,
write(X1),nl,
write(X2),nl,
write(X3),nl,
write(X4),nl.
%-------------------
When executed under yap (go/1 first and then goread/1), it returns:
Type something, end with dot: jrjkerjt.
First line of 'aaa'
First line of 'bbb'
jrjkerjt
First line of 'aaa'
yes
SWI-prolog and gprolog return instead:
% Swipl
Type something, end with dot: djkjhrt.
First line of 'aaa'
end_of_file
djkjhrt
Second line of 'aaa'
true.
%gprolog
Type something, end with dot: dksjdhf.
First line of 'aaa'
end_of_file
dksjdhf
Second line of 'aaa'
(1 ms) yes
It seems that both swipl and gprolog keep the same file pointer for
aaa and for bbb, which should instead be two different sources each
with its pointer.
I'm not a prolog programmer (not yet). I just try pieces of code to
understand the working of the prolog engine, and if the code I pasted
is not correct, or if it may be written in a better (and satisfactory)
way, please tell me.
--------------------------
Antonio Maschio
<tbin at libero dot it>
_______________________________________________
Users-prolog mailing list
address@hidden
http://lists.gnu.org/mailman/listinfo/users-prolog