Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!uunet!husc6!cmcl2!brl-adm!brl-smoke!broome From: broome@brl-smoke.ARPA (Paul Broome ) Newsgroups: comp.lang.prolog Subject: Re: Badness Message-ID: <6669@brl-smoke.ARPA> Date: Thu, 12-Nov-87 16:16:30 EST Article-I.D.: brl-smok.6669 Posted: Thu Nov 12 16:16:30 1987 Date-Received: Sat, 14-Nov-87 19:35:13 EST References: <8711090842.AA20806@ucbvax.Berkeley.EDU> <2385@mulga.oz> <4815@burdvax.PRC.Unisys.COM> Reply-To: broome@brl.arpa (Paul Broome (CTAB) ) Organization: Ballistic Research Lab (BRL), APG, MD. Lines: 27 Keywords: declarative programming Summary: IF-THEN-ELSE is not required It's not clear that IF-THEN-ELSE is essential for programming. In fact it's often hazardous! The ELSE part of an IF-THEN-ELSE is too all-enclosing. A small example that immediately comes to mind is factorial, often written something like fac(N) = if N=0 then 1 else N*fac(N-1). The danger comes from permitting an unbounded recursion for negative N. It's much better, in this case at least, to say explicitly what cases can be handled and fail for those outside. E.g. something like fac(N) = if N=0 then 1 if N>0 then N*fac(N-1). It would be interesting to see a small example that *requires* IF-THEN-ELSE? Paul , p.s. This was prompted by the following: In article <4815@burdvax.PRC.Unisys.COM> blenko@burdvax.PRC.Unisys.COM (Tom Blenko) writes: >Programming declaratively, in the sense of pure PROLOG (without call(), >not(), and cut()) is not even powerful enough to express IF-THEN-ELSE, >which I am willing to assume is a _sine_qua_non_ for programming.