Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!unmvax!pprg.unm.edu!hc!lll-winken!uunet!mcvax!ukc!icdoc!cdsm From: cdsm@doc.ic.ac.uk (Chris Moss) Newsgroups: comp.lang.prolog Subject: Re: Committed Choice Keywords: cut if-then-else Message-ID: <751@gould.doc.ic.ac.uk> Date: 4 Apr 89 14:33:21 GMT References: <11500012@hpldola.HP.COM> <733@gould.doc.ic.ac.uk> <18798@adm.BRL.MIL> <192@aucsv.UUCP> Reply-To: cdsm@doc.ic.ac.uk (Chris Moss) Organization: Dept. of Computing, Imperial College, London, UK. Lines: 37 In article <8209@russell.STANFORD.EDU> pereira@russell.UUCP (Fernando Pereira) writes: >: : repeat, >: : { Body } >: : ( -> ! >: : ; -> fail >: : ). 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. Is there any way such a program can run out of memory? To make the situation more concrete, here is a toy program which simply reads a file and throws it away. But it does attempt to use permanent variables and introduce choice points, although these are then thrown away. It does NOT produce any garbage. re(File) :- see(File), tailrec, seen. tailrec :- r, !, tailrec. tailrec :- write(ok). r :- c(X),!, X\== -1. % -1 is end of file r. c(X) :- get0(X). c(X) :- fail. Can anyone produce a similar program that DOES make any one of the standard stacks overflow? Chris Moss