🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.prolog
Article #2500

Re: PROLOG Digest V4 #80

#2500
From: ECTU68 R Innis CS
Date: Wed, 03 Dec 1986 12:22
33 lines
1934 bytes
Expires:

Acknowledgement: Paul Brna, who explained this notation to me....


In PROLOG Digest V4 #80 John Cugini <cugini@nbs-vms.arpa> writes:
>%%
>%%  Many of these predicates expect certain of their arguments to be
>%%  instantiated upon invocation.  When such restrictions apply it is
>%%  usually the leading arguments which are thought of as input (and
>%%  hence instantiated), and the trailing arguments as output (and hence
>%%  allowed to be uninstantiated).
>%%

A standard way (at least, in Edinburgh) of denoting the status of arguments to 
a Prolog predicate is to include a comment line before the body of the clause,
in which arguments expected to be instantiated are prefixed by '+', 
uninstantiated arguments by a '-', and arguments where it doesn't matter (or 
where either can be used) by '?'. For example,

%% Append(+L1, +L2, -L3)

indicates the status of the arguments to the usual use of the standard 'append'
clause. To illustrate further uses, further comments could be added, viz:

%% Append(+L1, -L2, +L3) is the calling pattern for finding if L1 is a member 
%% of L3. (?L2 would also be acceptable).

In use, I've found that this notation makes Prolog code much easier to read
and understand, which given some of what is possible in Prolog is a very
desirable attribute. What say anyone else?

	--Rick Innis.
Technical Details
Message-ID: <157@its63b.ed.ac.uk>
Path: arc1-ca.pugleaf.net!utzoo!mnetor!seismo!mcvax!ukc!its63b!csrdi

Show Full Headers
Complete Article Headers
Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP
Path: arc1-ca.pugleaf.net!utzoo!mnetor!seismo!mcvax!ukc!its63b!csrdi
From: csrdi@its63b.ed.ac.uk (ECTU68 R Innis CS)
Newsgroups: comp.lang.prolog
Subject: Re: PROLOG Digest   V4 #80
Message-ID: <157@its63b.ed.ac.uk>
Date: Wed, 3-Dec-86 07:22:01 EST
Article-I.D.: its63b.157
Posted: Wed Dec  3 07:22:01 1986
Date-Received: Fri, 5-Dec-86 05:42:09 EST
Reply-To: csrdi@itspna.uucp (Rick Innis, CS3)
Organization: I.T. School, Univ. of Edinburgh, U.K.
Lines: 28
Summary: How to indicate status of arguments in Prolog