From jan@swi.psy.uva.nl Thu Apr 19 10:42:35 2001
Received: from gollem.swi.psy.uva.nl (root@gollem [145.18.152.30])
	by swi.psy.uva.nl (8.11.2/8.11.2) with ESMTP id f3J8gZ327659;
	Thu, 19 Apr 2001 10:42:35 +0200 (MET DST)
Received: from localhost (localhost [[UNIX: localhost]])
	by gollem.swi.psy.uva.nl (8.11.2/8.11.2/SuSE Linux 8.11.1-0.5) id f3J8gZd01314;
	Thu, 19 Apr 2001 10:42:35 +0200
From: Jan Wielemaker <jan@swi.psy.uva.nl>
Organization: SWI, University of Amsterdam
To: David Poole <poole@cs.ubc.ca>, prolog@swi.psy.uva.nl
Subject: Re: [SWIPL] bug (or feature) in initialization
Date: Thu, 19 Apr 2001 10:31:26 +0200
X-Mailer: KMail [version 1.0.29.2]
Content-Type: text/plain
References: <3ADE7E9C.9B39D0F0@cs.ubc.ca>
In-Reply-To: <3ADE7E9C.9B39D0F0@cs.ubc.ca>
MIME-Version: 1.0
Message-Id: <01041910423500.00723@gollem>
Content-Transfer-Encoding: 8bit

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

