🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.prolog
Article #3222

Re: Yet another stupid question

#3222
From: Richard A. O'Keefe
Date: Sat, 09 Apr 1988 01:01
40 lines
2336 bytes
In article <3379@crcge1.UUCP>, ranson@crcge1.UUCP (D. Ranson CNET) writes:
> 
> What is the difference between the ?- and :- operators in front of a
> goal? I have seen both used in several Prolog books or manuals, with
> no discernable pattern, and without any explanation.
> 
>      Daniel Ranson
>      ...!mcvax!inria!crcge1!ranson

What the difference is depends on the Prolog system.

In DEC-10 Prolog, the rule is that ":-" begins "commands" and "directives".
When one of these things is encountered in a file, it is processed and no
output is produced unless something goes wrong.  "?-" begins "queries",
and the bindings produced by such queries are printed exactly as if you
had typed the query at top level.  That's why the top level prompt
includes "?- ".  If you want to give a command at top level and not have
any bindings printed, you can use :-.  For example
	| ?-  :- source_file(p(_), File), compile(File).
	===== ------------------------------------------
	prompt           command
will not print the binding of File.

PDP-11 Prolog, in order to save space (it ran on PDP-11s without separate
I&D space, and 64kbytes is not a large address space) didn't allow an
operator to be both infix and prefix, so in PDP-11 Prolog you had to use
?- for commands and directives, and couldn't put queries in files.

Quintus Prolog doesn't distinguish between ?- and :- in files.
I'd never actually noticed this, because I've never wanted to put a query
in a file and have the bindings printed on the terminal.  However, the
trick of putting a :- in front of a top-level query to suppress the printing
of the bindings is supported.

I suggest that you forget about ?- and stick to :- .  If you come across
a Prolog system where you have to use ?- you will probably have to make a
lot of other changes as well.

Check your books again, though.  They may be writing the ?- to show you
the top-level prompt, as I did in the example above.
Technical Details
Message-ID: <861@cresswell.quintus.UUCP>
Path: arc1-ca.pugleaf.net!utzoo!mnetor!uunet!seismo!sundc!pitstop!sun!quintus!ok
References: <3379@crcge1.UUCP>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!mnetor!uunet!seismo!sundc!pitstop!sun!quintus!ok
From: ok@quintus.UUCP (Richard A. O'Keefe)
Newsgroups: comp.lang.prolog
Subject: Re: Yet another stupid question
Message-ID: <861@cresswell.quintus.UUCP>
Date: 9 Apr 88 01:01:25 GMT
References: <3379@crcge1.UUCP>
Organization: Quintus Computer Systems, Mountain View, CA
Lines: 40