Theory and Practice of Logic Programming

Regular Papers

Coding guidelines for Prolog

MICHAEL A. COVINGTONa1, ROBERTO BAGNARAa2 *, RICHARD A. O'KEEFEa3, JAN WIELEMAKERa4 and SIMON PRICEa5

a1 Institute for Artificial Intelligence, The University of Georgia, Athens, GA, USA (e-mail: mc@uga.edu)

a2 Department of Mathematics, University of Parma, Itlay BUGSENG srl, Parma, Italy (e-mail: bagnara@cs.unipr.it)

a3 Department of Computer Science, University of Otago, Dunedin, New Zealand (e-mail: ok@cs.otago.ac.nz)

a4 Department of Computer Science, VU University Amsterdam, The Netherlands (e-mail: j.wielemaker@cs.vu.nl)

a5 Intelligent Systems Laboratory, University of Bristol, Bristol, UK (e-mail: simon.price@bristol.ac.uk)

Abstract

Coding standards and good practices are fundamental to a disciplined approach to software projects irrespective of programing languages being employed. Prolog programing can benefit from such an approach, perhaps more than programing in other languages. Despite this, no widely accepted standards and practices seem to have emerged till now. The present paper is a first step toward filling this void: It provides immediate guidelines for code layout, naming conventions, documentation, proper use of Prolog features, program development, debugging, and testing. Presented with each guideline is its rationale and, where sensible options exist, illustrations of the relative pros and cons for each alternative. A coding standard should always be selected on a per-project basis, based on a host of issues pertinent to any given programing project; for this reason the paper goes beyond the mere provision of normative guidelines by discussing key factors and important criteria that should be taken into account when deciding on a full-fledged coding standard for the project.

(Received November 15 2009)

(Revised November 11 2010)

(Accepted May 02 2011)

(Online publication June 30 2011)

KEYWORDS:

  • Prolog;
  • style;
  • coding standards;
  • debugging;
  • efficiency

Footnotes

*  The work of R. Bagnara has been partly supported by PRIN project “AIDA2007 – Abstract Interpretation Design and Applications.”