Path: utzoo!utgpu!watserv1!watmath!att!att!linac!pacific.mps.ohio-state.edu!zaphod.mps.ohio-state.edu!usc!cs.utexas.edu!uunet!munnari.oz.au!goanna!ok From: ok@goanna.cs.rmit.oz.au (Richard A. O'Keefe) Newsgroups: comp.lang.prolog Subject: Re: Problem - interaction of consult/1 with see/1 and seen/0. Message-ID: <4178@goanna.cs.rmit.oz.au> Date: 1 Nov 90 08:35:34 GMT References: <1990Oct31.123459.3754@and.cs.liv.ac.uk> Organization: Comp Sci, RMIT, Melbourne, Australia Lines: 43 In article <1990Oct31.123459.3754@and.cs.liv.ac.uk>, dave8@and.cs.liv.ac.uk writes: > I have run into a problem that occurs with the implementations of Prolog that > we have. When consulting, if see/1 and/or seen/0 is called inside the file > being consulted (yes, I actually wanted to do this in a test program!), the > Prolog concerned switches, after finishing with the directive in which > "see( File )" or "seen" occurs, to consulting "File" or "user" respectively. Why does it surprise you when your system works? Here's how seen/0 works: seen :- seeing(CurrentInput), see(user), close(CurrentInput). (You may have been thinking of 'see' as a kind of 'push' and 'seen' as a kind of 'pop'. If you were, stop it at once. It doesn't work that way and never has.) There _is_ a difference between Prolog systems: in many Prolog systems consult(File) makes File the current input, some (including Quintus) don't. This really shouldn't make any difference to you, because the right way to divert attention to some other file is seeing(OldInput), see(NewFile), /* do something that reads from NewFile */ see(OldInput), % make OldInput current again close(File) or seeing(OldInput), see(NewFile), /* do something that reads from NewFile */ seen, see(OldInput) Either of those should work in any "Edinburgh-compatible" system. -- The problem about real life is that moving one's knight to QB3 may always be replied to with a lob across the net. --Alasdair Macintyre.