Path: utzoo!attcan!uunet!zephyr.ens.tek.com!uw-beaver!rice!cs.utexas.edu!samsung!zaphod.mps.ohio-state.edu!mips!apple!sun-barr!newstop!texsun!smunews!ti-csl!vlsic2!brahme From: brahme@vlsic2.ti.com (Dan Brahme) Newsgroups: comp.lang.prolog Subject: Re: Legitimate uses of "assert"? Message-ID: <112803@ti-csl.csc.ti.com> Date: 1 Mar 90 15:38:32 GMT References: <8205@pt.cs.cmu.edu> <1708@sequent.cs.qmw.ac.uk> Sender: news@ti-csl.csc.ti.com Organization: Texas Instruments Inc, SPDC Operations, Dallas, TX Lines: 35 mmh@cs.qmw.ac.uk (Matthew Huntbach) writes: >"assert" and "retract" are best used to get round what I >believe is a very awkward problem with Prolog, the fact that >computations on the OR-branches of search trees cannot >otherwise communicate. >e.g >pred() :- body1 >pred() :- body2 >Suppose body1 fails, but some of the partial calculations done >within it are useful in body2. Then you have to use "assert" >to pass them on. >I still don't think this is in good taste. I would prefer >something like: >pred() :- body1',body2'. >where body1' passes on any information required to body2' and >has a flag which if set to "true" causes body2' to immediately >halt. >Matthew Huntbach I think you can avoid the use of assert in the situation you mentioned. There are ; and -> clauses introduced in several prologs (quintus has them definitely), which precisely serve this purpose. Dan brahme Texas Instruments