Newsgroups: comp.lang.prolog
Path: cantaloupe.srv.cs.cmu.edu!das-news2.harvard.edu!news2.near.net!news.mathworks.com!udel!gatech!howland.reston.ans.net!Germany.EU.net!Munich.Germany.EU.net!ecrc!news
From: joachim@ecrc.de (Joachim Schimpf)
Subject: Re: Indexing
Message-ID: <D7Dryn.F9p@ecrc.de>
Sender: news@ecrc.de
Reply-To: joachim@ecrc.de
Organization: European Computer-Industry Research Centre GmbH, Munich, Germany
References: <3mvo1s$dpk@idefix.CS.kuleuven.ac.be>
Date: Fri, 21 Apr 1995 10:32:46 GMT
Lines: 42

In article dpk@idefix.CS.kuleuven.ac.be, bimbart@CS.kuleuven.ac.be (Bart Demoen) writes:
>Fergus Henderson asks:
>
>> I am curious to know why most Prolog implementations has such
>> dismal indexing (usually limited to top functor, first argument)
>> when indexing has such a big impact on performance. Why do
>
>...
>
>At BIM, we were lucky in this respect: we had multiple argument
>indexing before we had clients :-) ... more than 10 years ago !
>Unfortunately only on principal functors :-(


It may be interesting to note that ECLiPSe has adopted a solution in between:

- the compiler generates independent indexes for every argument
  (well, every argument where an index could make sense).

- at call time, a 'useful' one of these indexes is selected
  (depending on the call pattern and some heuristics) and used.

While this solution still does not exploit the full potential of indexing,
it can make programming much more convenient. In particular, there is no
need to ever reshuffle arguments in order to move something to the first
position: the argument order has no impact on performance.
Another advantage is that e.g. predicates like

colour(black, 0).
colour(red,   1).
colour(green, 2).
colour(blue,  3).
colour(white, 4).

will be deterministic no matter whether used forwards or backwards.

---------------------------------------------------------------------------
 Joachim Schimpf                                 Email   joachim@ecrc.de 
 European Computer-Industry Research Centre      Phone   +49 89 92699 111
 Arabellastrasse 17, D-81925 Munich, Germany     Fax     +49 89 92699 170


