Subject: Re: [SWIPL] bug (or feature) in initialization

From: Jan Wielemaker <[email-masked]>
Date: Thu, 19 Apr 2001 10:31:26 +0200

On Thu, 19 Apr 2001, David Poole wrote:
>Hi All,
>I have a simple logic programming interpreter that I want to start up
>when I load a file. My "start" predicate is a read-eval-print loop. I
>want to do:
>:- initialization(start).
>This works in Sicstus Prolog. However in SWI prolog, when start does a
>"read", it doesn't read from the terminal (as I would like, and as
>Sicstus does) it instead gets a end_of_file (^D) which I don't like (my
>program doesn't like it either).  I think this a bug. (Note that this
>has the same behaviour (in SWI and in Sicstus) if I do:
>:- start.

For mostly historical reasons, SWI-Prolog changes the current input
stream to the file it is loading and doesn't change this when executing
queries.  This will surely be fixed/changed someday, but for now I
propose to do

swi_start :-
	seeing(Old), see(user),
	(   start
	->  seen, see(Old)
	;   seen, see(Old), fail
	).

or something along these lines.
	
>While I am asking questions. Is there any chance of getting
>"when(Cond,Goal)", as in Sicstus Prolog implemented in SWI Prolog? This
>is a very useful predicate that cannot be implemented without hacking
>the internals of Prolog. (I want to delay negation as failure and for
>unbound goals and inequalities that cannot be immediately resolved in my
>meta-interpreter).

But it isn't trivial inside Prolog too as it requires the
implementation of co-routing.  Especially as it isn't part of the ISO
standard I have no concrete plans for the time being.  Of course, if
someone wants to give it a try, I'm willing to provide assistance.

>If anyone is interested, the logic programming interpreter is CILog
>obtainable from:
>http://www.cs.ubc.ca/spider/poole/ci/code/cilog/cilog_man.html
>and the code from:
>http://www.cs.ubc.ca/spider/poole/ci/code/cilog/cilog_swi.pl

If it works on SWI-Prolog, please add a node to the Prolog twiki web.

	--- Jan