Newsgroups: comp.lang.prolog
Path: cantaloupe.srv.cs.cmu.edu!das-news.harvard.edu!news2.near.net!MathWorks.Com!yeshua.marcam.com!usc!howland.reston.ans.net!math.ohio-state.edu!jussieu.fr!univ-lyon1.fr!swidir.switch.ch!newsfeed.ACO.net!Austria.EU.net!EU.net!uunet!munnari.oz.au!cs.mu.OZ.AU!munta.cs.mu.OZ.AU!lee
From: lee@munta.cs.mu.OZ.AU (Lee Naish)
Subject: Re: Avoiding use of univ operator
Message-ID: <9425619.6066@mulga.cs.mu.OZ.AU>
Sender: news@cs.mu.OZ.AU
Organization: Department of Computer Sci, University of Melbourne
References: <34irt9$lk1@gnu.mat.uc.pt> <34k2fr$73r@goanna.cs.rmit.oz.au> <pmoura-1309940219080001@slip.uc.pt>
Date: Tue, 13 Sep 1994 09:28:31 GMT
Lines: 64

In article <pmoura-1309940219080001@slip.uc.pt> pmoura@alma.uc.pt (Paulo Moura) writes:
>In article <34k2fr$73r@goanna.cs.rmit.oz.au>, ok@goanna.cs.rmit.oz.au
>(Richard A. O'Keefe) wrote:

>>>       functor( Predicate, Argument ) :-
>>>               Predicate( Argument).

>>  foo(Predicate, Argument) :-
>>     call(Predicate, Argument).
>
>In LPA implementations (an according to their manuals) the former is
>more efficient that using the call() predicate that, I assume, is  
>implemented using arg(), functor() and/or =..

LPA isn't necessarily implemented in the most efficient way.

>Anyaway, I think that writing "Predicate( Argument )" is a bit more
>declarative that "call(Predicate, Argument)". For instance compare:
>
>      ..., retract( Pred(Arg) ), ...
>
>with:
>
>    ..., Retract =.. [Pred,Arg], retract( Retract ), ...

Granted, in this case the "feature" leads to more concise code.
I wouldn't say either was declarative though!

>      ..., Call =.. [Pred,Arg], findall( Arg, Call, List ), ...

The following works just fine:
      ..., findall( Arg, call(Pred, Arg), List ), ...

>>This is to be understood as a *specification*:  it is not only *possible*
>>to implement the call/(N+1) family much more efficiently, it is even rather
>>easy (...).

> Efficiently ? Do you mean implement separate definitions
>for call/1, call/2, ... ?

You can do that with a library (as was done in Quintus, up to N=6 I
think).  If call/N is a builtin then the *compiler* can do the work and
N can be unbounded.


Allowing variables as functors doesn't buy you that much (it makes some
code more concise) and it does make *the* data structure of Prolog
(terms) less "structured" in some sense (which has consequences for all
sorts of things, including indexing as Richard mentioned).  If functors
can be variables which can be bound to arbitrary terms then terms are
essentially (unlabelled) tuples (normal Prolog terms can be thought of
as tuples labelled with the functor).

The difference in the fundamental data structure of Edinburgh Prolog
and LPA Micro Prolog has had very unfortunate consequences.  About a
decade ago a committee was set up to put together a BSI standard for
Prolog, based on Edinburgh Prolog.  Regrettably, the committee decided
to invent a new language based on a combination of Edinburgh Prolog and
LPA Micro Prolog (amongst other things).  What followed was a long, drawn
out, slow, time consuming (get the picture?) retreat towards Edinburgh
Prolog.  The lack of a good timely Prolog standard has cost the Prolog
community a great deal.

	lee
