🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: comp.lang.prolog
1 messages
1 total messages Started by Glenn Holliday Tue, 03 Nov 1992 15:27
CUT in procedural applications
#48
Author: Glenn Holliday
Date: Tue, 03 Nov 1992 15:27
32 lines
1938 bytes
	Question of style for finished applications in Prolog.  What is
the prevailing opinion/practice for cuts?

     It seems to me that applications which do procedural work need a lot more
cuts than the books recommend.  I understand why it's a good thing to get rid
of cuts.  But most procedural predicates should have guaranteed deterministic
behavior.  Cut is the way to guarantee that.  For instance,

  program :-
     getInput(SomeInput),
     proveStuffAboutInput(SomeInput, SomeOutput),
     writeOutput(SomeOutput).

     The non-logical procedures getInput/1 and writeOutput/1, once they are
first satisfied, should never be backtracked into.  Assuming each has some
subgoals for which the same thing is true, 2/3 of the program should be
protected by cuts.

     Some predicates can be written so that unwanted backtracking will never
match the arguments.  The trivial cases of predicates with a single clause,
and the last predicate satisfied, never need cuts.  But I believe these cases
are in the minority for procedural code which models lots of if-type choices. 

	I measured a real application I wrote, with 809 clauses and 491 cuts. 
There's probably some room for improvement there, but I think that's in the
ballpark for what this type of application really needs.  Am I missing
something, or do Prolog programmers at large find this to be true?

	Looking forward to your comments,
-- 
Glenn Holliday | holliday@csgrad.cs.vt.edu
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads