Article View: comp.lang.prolog
Article #1062Prolog Prog. Technique Question
From: Timothy R. Gottschalk
Date: Sun, 12 Aug 1990 21:15
Date: Sun, 12 Aug 1990 21:15
22 lines
1326 bytes
1326 bytes
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.
Technical Details
Message-ID:
<kalQPim00WB242VkMS@andrew.cmu.edu>Path:
arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!pt.cs.cmu.edu!andrew.cmu.edu!tg1e+Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!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: <kalQPim00WB242VkMS@andrew.cmu.edu> Date: 12 Aug 90 21:15:26 GMT Organization: Carnegie Mellon, Pittsburgh, PA Lines: 22