🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.prolog
Article #1090

Prolog PROG TECH. II

#1090
From: Timothy R. Gottschalk
Date: Sat, 18 Aug 1990 19:14
34 lines
2160 bytes
In my earlier post, I neglected to include a very important cut in my
loop.  I am the first to admit cluelessness in Prolog programming, so
perhaps someone out there can give me some help optimizing use of the
heap w/ the following Turbo Prolog loop (in repeat ... fail form):
...........................................................................
run(Event_In):-                             % run takes a member of a special
     call_eval(Event_In, Event_Out),        % domain as an argument.
     Event_Out = done,!.                    % loop finished when symbol 'done'
                                            % is returned.
call_eval(Event, Event).
call_eval(Event_In, Event_Done):-
     exec_event(Event_In, Event_Out),       % SEE BELOW FOR exec_event***
     call_eval(Event_Out, Event_Done).

Notes on flow patterns:
    call_eval/2 is (i,o), exec_event/2 is (i,o), run/1 is (i)

*** exec_event takes an event and ultimately returns a new event from the
    old one -- this is the root of my problem; I want to reuse the same
    heap space since I won't need to ever backtrack.  Using retract and
    assert makes the program run unacceptably slow; I guess due to the
    complexity of the event data structure.  Could I use ref variables
    or something like that?  My compiler insists that call_eval is non-
    deterministic, since putting a cut in the first instance of call_eval
   would be contrary to the idea of the repeat..fail.  But, wouldn't this
   be the source of my heap leakage problem?

   If you'd like to run this program yourself, insert a storage check in
   call_eval, and then write a body for exec_event like:

   exec_event(Event_In, Event_Out):-
      Event_Out = Event_In,!.

Tim G.
Technical Details
Message-ID: <ganNChe00WB2QF5VM0@andrew.cmu.edu>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!rutgers!cs.utexas.edu!tut.cis.ohio-state.edu!pt.cs.cmu.edu!o.gp.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!rutgers!cs.utexas.edu!tut.cis.ohio-state.edu!pt.cs.cmu.edu!o.gp.cs.cmu.edu!andrew.cmu.edu!tg1e+
From: tg1e+@andrew.cmu.edu (Timothy R. Gottschalk)
Newsgroups: comp.lang.prolog
Subject: Prolog PROG TECH. II
Message-ID: <ganNChe00WB2QF5VM0@andrew.cmu.edu>
Date: 18 Aug 90 19:14:53 GMT
Organization: Carnegie Mellon, Pittsburgh, PA
Lines: 34