Newsgroups: comp.lang.prolog
Path: cantaloupe.srv.cs.cmu.edu!das-news.harvard.edu!news2.near.net!MathWorks.Com!yeshua.marcam.com!usc!elroy.jpl.nasa.gov!decwrl!amd!amdahl!netcomsv!ix.netcom.com!netcom.com!ludemann
From: ludemann@netcom.com (Peter Ludemann)
Subject: Re: What exactly is LIPS?
Message-ID: <ludemannCwyC5y.5Av@netcom.com>
Summary: Prolog code usually uses simple unifcation without backtracking
Keywords: nrev LIPS optimization
Organization: NETCOM On-line Communication Services (408 261-4700 guest)
References: <Y222338.940928.A@ozemail.com.au> <36e057$23f@irisa.irisa.fr> <36fp20$cne@hobbes.cc.uga.edu>
Date: Fri, 30 Sep 1994 16:51:30 GMT
Lines: 48

In article <36fp20$cne@hobbes.cc.uga.edu>,
Michael Covington <mcovingt@ai.uga.edu> wrote:

>Note that naive reverse uses unification in a trivial way and performs no
>backtracking; thus, the two most important features of the language are
>left unused.  

While I'm no fan of "nrev LIPS", I'm not sure I agree with Michael's
statement.  I think that most of my code uses unification in a
"trivial way" (see example below) and most of it doesn't backtrack.

Complex unification and backtracking are useful things to have (and
not having them would cripple Prolog); but I don't think they're often
used.  In fact, one important use of a profiler is to find places
where choicepoints are created and not needed---that is, where the
compiler thinks that backtracaking is possible but the implementor
knows that backtracking won't (or should be an error).

While it's true that many Prolog vendors have optimized append/3 (to
get good LIPS?), it's also true that that class of optimization is a
Good Thing to have.

Typical code:

foo([], []).
foo([X|Xs], [Y|Ys]) :-
	transform(X, Y),
	foo(Xs, Ys).

/* Yes, this does look like the expansion of maplist(transform,Xs,Ys) */
/* It also looks like a generalization of append/3:
	bar([], Z, Z).
	bar([X|Xs], Z, [Y|Ys]) :-
		transform(X, Y), % for append, this is X=Y
		bar(Xs, Z, Ys).
*/

p(f1(X),   Z) :- ...
p(f2(X),   Z) :- ...
p(f3(X,Y), Z) :- ...
	...

Given these pieces of typical code, and the desire to write code
that runs fast, the most useful things are: good macro-processing,
ability to recognize append-like code, and good argument indexing.

-- 
Peter Ludemann                      ludemann@netcom.com
