Re: see/seen, tell/told

Daniel Diaz <[email protected]>
Newsgroups gmane.comp.gnu.prolog.general
Message-ID <[email protected]>
Hi Antonio,

tell/1 and friends are obsolete beasts. If you want a portable code 
(across Prolog systems) you should use ISO predicates (e.g. open/3-4 ...).

Daniel


Antonio Maschio wrote:
> 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
> [email protected]
> http://lists.gnu.org/mailman/listinfo/users-prolog
>


-- 
Ce message a ete verifie par MailScanner
pour des virus ou des polluriels et rien de
suspect n'a ete trouve.
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.