Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!seismo!rutgers!ames!ucbcad!ucbvax!SU-SCORE.ARPA!PROLOG-REQUEST From: PROLOG-REQUEST@SU-SCORE.ARPA (Chuck Restivo, The Moderator) Newsgroups: comp.lang.prolog Subject: PROLOG Digest V4 #82 Message-ID: <8612080831.AA23955@ucbvax.Berkeley.EDU> Date: Sun, 7-Dec-86 09:58:00 EST Article-I.D.: ucbvax.8612080831.AA23955 Posted: Sun Dec 7 09:58:00 1986 Date-Received: Mon, 8-Dec-86 05:40:56 EST Sender: daemon@ucbvax.BERKELEY.EDU Reply-To: PROLOG@SU-SCORE.ARPA Organization: The ARPA Internet Lines: 67 PROLOG Digest Monday, 8 Dec 1986 Volume 4 : Issue 82 Today's Topics: Programming - Comment Style ---------------------------------------------------------------------- Date: 7 Dec 86 06:04:14 GMT From: Bruce T. Smith Subject: comment style I like that kind of comment, too. In the Prolog systems I've used, they are only comments, so it's safe to extend it a bit. For example: 1) Give multiple specifications when appropriate. E.g., foo(+X,-Y) and foo(-X,+Y) might make sense for a clause, and are not the same as foo(?X,?Y). 2) For some patterns of instantiated variables a particular argument may be ignored. I use a prefix '_', like the anonymous variable. 3) Use types, e.g., foo(+Int,-Float). -- Bruce T. Smith ------------------------------ Date: 3 Dec 86 12:22:01 GMT From: R. Innis Subject: Style 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 ------------------------------ End of PROLOG Digest ********************