Path: utzoo!utgpu!news-server.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!pt.cs.cmu.edu!andrew.cmu.edu!tg1e+ From: tg1e+@andrew.cmu.edu (Timothy R. Gottschalk) Newsgroups: comp.lang.prolog Subject: Prolog Prog. Technique Question Message-ID: Date: 12 Aug 90 21:15:26 GMT Organization: Carnegie Mellon, Pittsburgh, PA Lines: 22 I took a course that introduced Prolog syntax, but never touched prog. techniques. Thus, I am feeling my way through. I am writing code similiar to the following structure (in Turbo Prolog V2.0): loop(In):- check_mouse, do_eval(In, Out), loop(Out). loop(_):- do_exit. The compiler recognizes that it is tail-recursive, but still allocates memory off the heap during each iteration. As the loop should only be run when the mouse button is pressed, the check_mouse succeeds when the button is pressed, but fails otherwise. Commenting out the check_mouse or do_eval call does not necessarily stop the heap allocation, although commenting out both certainly does (of course). The easiest solution would be to make a predicate fail somewhere, but, then, how would I be able to get a return value? (Using reference vars or internal dbases seems to make the program run unacceptably slow). Tim G.