Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!ucbvax!ucsd!rutgers!cmcl2!adm!broome From: broome@adm.BRL.MIL (Paul Broome ) Newsgroups: comp.lang.prolog Subject: Re: Committed Choice Keywords: cut if-then-else Message-ID: <18798@adm.BRL.MIL> Date: 23 Mar 89 17:09:20 GMT References: <11500012@hpldola.HP.COM> <733@gould.doc.ic.ac.uk> <1305@murtoa.cs.mu.oz.au> <8209@russell.STANFORD.EDU> Reply-To: broome@brl.arpa (Paul Broome (CSMB) ) Organization: Ballistic Research Lab (BRL), APG, MD. Lines: 46 Here's one alternative I've seen that's only slightly cleaner: Define repeat(Body,Until) :- repeat, Body, Until, !. Then we can accomplish the same thing with ... repeat(, ). -Paul In article <8209@russell.STANFORD.EDU> pereira@russell.UUCP (Fernando Pereira) writes: :In Edinburgh-family Prolog systems, the scope of a cut is the whole :clause in which it appears, even it the cut is inside a conditional. :This is a very useful control behavior, messy to simulate with cuts :that stay inside the scope of conditionals. For example, the following :is a common way of terminating a repeat/fail loop: : : ... : repeat, : ... : ( -> ! : ; -> fail ). : :I will agree with anybody that this is not a pristine example of :declarative programming, but such things *are* needed in the imperfect :logic-programming languages we have today. I also appreciate that we :could move the cut to after the conditional with the same result, but :there are more complicated situations, which I don't have the time now :to discuss, in which that alternative is not available. : :Fernando Pereira :AI Center :SRI International :pereira@ai.sri.com Paul Broome broome@brl.arpa