Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!sharkey!shadooby!accuvax.nwu.edu!tank!ncar!unmvax!pprg.unm.edu!hc!lll-winken!uunet!mcvax!unido!ecrcvax!micha From: micha@ecrcvax.UUCP (Micha Meier) Newsgroups: comp.lang.prolog Subject: Re: Committed Choice Keywords: cut if-then-else garbage collection Message-ID: <711@ecrcvax.UUCP> Date: 6 Apr 89 08:53:08 GMT References: <11500012@hpldola.HP.COM> <733@gould.doc.ic.ac.uk> <18798@adm.BRL.MIL> <192@aucsv.UUCP> <751@gould.doc.ic.ac.uk> Reply-To: micha@ecrcvax.UUCP (Micha Meier) Organization: ECRC, Munich 81, West Germany Lines: 28 In article <751@gould.doc.ic.ac.uk> cdsm@doc.ic.ac.uk (Chris Moss) writes: >What I'd like to know is: is there EVER any good reason for using a >repeat loop, with current Prolog technology? > >Repeat loops are basically of value for side effect programs such as >file readers, compilers etc. They don't do any global binding of variables >so they can be represented by parameterless procedures (or procedures that >take only input bindings). Thus they do not produce garbage on the stack >if the top level is a tail recursive procedure. Chris, why do you think repeat loops are of value only for file readers, compilers etc.? When such programs do not produce garbage on the global stack then of course the repeat loops are *not* of value for them, you can use tail recursion instead, which is faster. The repeat loops are useful for programs which do create garbage on the global stack because the garbage can be disposed of without the garbage collector. It is certainly not necessary to use repeat loops if your Prolog system has a garbage collector, but failure is a very simple and efficient way of a partial garbage collection. It is also possible to write a preprocessor that adds to your tail-recursive program control primitives that make the garbage collection faster (garbage cut of Jonas Barklund), but the failure loops will still remain as a valid alternative, I think. --Micha