Prev No Next Up Home Keys Figs Search New

Prolog XREF Analyser

Appeared in Volume 10/2, May 1997

Keywords: cross-references.


Frank.Moehle@Informatik.Uni-Oldenburg.de
Frank Moehle
10th February 1997

I am looking for a program that checks for unused Prolog clauses (unused = defined, but not referenced).


tom@rahul.net
Tom Howland
10th February 1997

I wrote such a thing long ago. It is the cross referencer that is distributed with Quintus 3.2. It is, however, public domain. A copy can be found at:
http://www.rahul.net/tom/hacks.html


inaf@inaf.com
Nathan Finstein
12th February 1997

A nice thing about Prolog is that all information, logic and data both, is represented in the same form (Prolog terms). One can very easily write programs in Prolog to process Prolog source code. Don't try this in C.

I've written a solution to your problem, but it is incomplete in that it doesn't look inside of setof/3, bagof/3, findall/3, and call/1. It also does not handle grammer rules, module specifications, or declarations.

Please contact me if you want a copy of the program.


fjh@murlibobo.cs.mu.oz.au
Fergus Henderson
13th February 1997

One could as easily say: A nice thing about C is that all information - source code, executables, and data - is represented in the same form (bytes). One can very easily write programs in C to process files of bytes. :)

The fact is that Prolog syntax is not quite so simple as it appears. Writing correct programs in Prolog to process Prolog source code is often a fairly tricky task.

You're right that C is not the ideal language for these sort of transformation tasks; logic programming is an excellent choice. However, if one happened to have a Prolog parser and term display package written in C or C++, then this task would probably not be that much harder in C/C++ than in Prolog.

Nathan Finstein writes:
I've written a solution to your problem, but it is incomplete...

I don't think it will be easy to fill the gaps. In fact, due to the nature of Prolog, it is impossible to fill the gaps. Some code will illustrate this:

nasty :- read(X), call(X).

Although Prolog's simple syntax and the builtin Prolog parser (read/1) make it easy to write source-to-source transformations programs that work much of the time, Prolog's semantics often make it very difficult to write source-to-source programs that work correctly in all circumstances.

On this note, perhaps it is appropriate for me to point to P. Gabriel's classic "Lisp: Good News, Bad News, How to Win Big" paper, available via http://www.cs.washington.edu/research/projects/ai/www/worseisbetter/worseisbetter.html.

Prev No Next Up Home Keys Figs Search New