Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!seismo!lll-crg!mordor!sri-spam!sri-unix!hplabs!sdcrdcf!burdvax!bigburd!dowding From: dowding@bigburd.UUCP (John Dowding) Newsgroups: comp.lang.prolog Subject: Re: PROLOG Digest V4 #80 Message-ID: <2215@bigburd.UUCP> Date: Sun, 7-Dec-86 14:37:05 EST Article-I.D.: bigburd.2215 Posted: Sun Dec 7 14:37:05 1986 Date-Received: Mon, 8-Dec-86 03:31:02 EST References: <157@its63b.ed.ac.uk> Reply-To: dowding@bigburd.UUCP (John Dowding) Organization: System Development Corp., Paoli, PA Lines: 48 In article <157@its63b.ed.ac.uk> csrdi@itspna.uucp (Rick Innis, CS3) writes: >In PROLOG Digest V4 #80 John Cugini 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. I have found this notation a little bit misleading because it is unclear whether, for instance, when '+' is used, if the programmer intended the argument to be fully instantiated (i.e. ground), or simply non-variable. Also, it doesnt allow certain kinds of important distinctions to be made. For instance, a predicate might have a modeing foo(?,?) because the programmer intends it to be used with either the first or second argument instantiated, however, may not intend that it be called with both arguments uninstantiated. To express this, the programmer would have to write something like: foo(+,-) | foo(-,+) | foo(+,+). To me this seems kind of awkward. I dont have a better notation in mind. Any suggestions? John Dowding UUCP: {psuvax1 | bpa | sdcrdcf } !burdvax!bigburd!dowding ARPA: dowding@cis.upenn.edu