Path: utzoo!attcan!uunet!mcvax!unido!ecrcvax!micha From: micha@ecrcvax.UUCP (Micha Meier) Newsgroups: comp.lang.prolog Subject: Re: Clause fusion (Disjunctions) Message-ID: <539@ecrcvax.UUCP> Date: 19 May 88 07:41:06 GMT References: <983@cresswell.quintus.UUCP> <5501@megaron.arizona.edu> Reply-To: micha@ecrcvax.UUCP (Micha Meier) Organization: ECRC, Munich 81, West Germany Lines: 47 Posted: Thu May 19 08:41:06 1988 Actually I don't want to contribute to this very topic, Saumya has analyzed it in detail. What I'm concerned with is the indentation of disjunctions. Two forms which were presented are > > association(Stack, Key, Val, Result) :- > pop_stack(Key1, Val1, Stack, Stack1) -> > (Key1 \== Key -> > association(Stack1, Key, Val, Result) ; > (Val1 = Val, > Result = present > ) > ) ; > Result = conflict. >-------------------- > > >> association(Stack, Key, Val, Result) :- >> pop_stack(Key1, Val1, Stack, Stack1), >> ( Key1 \== Key -> >> association(Stack1, Key, Val, Result) >> ; Val1 = Val -> >> Result = present >> ; Result = conflict >> ). I find the two unreadable - what is the best way to indent the disjunctions so that the resulting clause is easy to read and understand? The general form of an if-then-else construct in a clause is p :- a, b, c, ((q, r, s) -> (t, u, v);(w, x, y)), d, e, f. Some of the parentheses can be omitted, but should they? Richard proposes that nested if-then-else's are treated at the same level, which leads to confusions since then the indentation is context dependent (an if-then-else inside another one cannot be indented independently). I have tried several variants, I have also seen various programs from other people but I'm still searching. Isn't this problem a topic for the standardization committee? The way if-then-else's and disjunctions are written influences greatly the readability of the programs, if you do it the wrong way round it's almost guaranteed that no-one will notice any 'declarative meaning' of the program. --Micha