Re: [eclipse-users] Newbie: not consecutive procedure clauses

From: Kish Shen <kisshen_at_...5...>
Date: Sun, 07 Jan 2007 19:32:19 +0000
Paulo Moura wrote:
> On 2007/01/06, at 23:25, Philippe de Rochambeau wrote:
>> Could someone please explain why my procedure clauses should be
>> "consecutive"?
> See the ECLiPSe documentation on the discontiguous/1 directive.
> Paulo
The discontigous directive allow claises for predicates to be 
discontigous, but it is generally not a good idea to have discontigous 
definitions of predicates -- it is best to keep all the clauses for a 
particular predicate together, In Philippe's example:

wizard(X):- hasBroom(X), hasWand(X).

The definition of wizard/1 is seperated by the defintion of hasWand/1. 
You can keep your definitions together in this way:

wizard(X) :- hasBroom(X), hasWand(X).


You should keep your definitions for a predicatde together because it is 
easier to read and uinderstand your code, and also it is easier to catch 
spelling errors in the predicate names -- if you have many wizard/1 
clauses, and one of them is misspelt (e.g. you have wizrd(harry) instead 
of wizard(harry)), this will show up as a discontigous error if 
wizd(harry) is not the last clause of your wizard/1 definitions).


Kish Shen
Received on Sun Jan 07 2007 - 19:32:29 CET

This archive was generated by hypermail 2.3.0 : Sat Aug 24 2019 - 21:14:55 CEST