Logtalk


Logtalk is an object-oriented logic programming language that extends and leverages the Prolog language with a feature set suitable for programming in the large. It provides support for encapsulation and data hiding, separation of concerns and enhanced code reuse. Logtalk uses standard Prolog syntax with the addition of a few operators and directives.
The Logtalk language implementation is distributed under an open source license and can run using a Prolog implementation as the back-end compiler.

Features

Logtalk aims to bring together the advantages of object-oriented programming and logic programming. Object-orientation emphasizes developing discrete, reusable units of software, while logic programming emphasizes representing the knowledge of each object in a declarative way.
As an object-oriented programming language, Logtalk's major features include support for both classes and prototypes, parametric objects, protocols, categories, multiple inheritance, public/protected/private inheritance, event-driven programming, high-level multi-threading programming, reflection, and automatic generation of documentation.
For Prolog programmers, Logtalk provides wide portability, featuring predicate namespaces, public/protected/private object predicates, coinductive predicates, separation between interface and implementation, simple and intuitive meta-predicate semantics, lambda expressions, definite clause grammars, term-expansion mechanism, and conditional compilation. It also provides a module system based on de facto standard core module functionality.

Examples

Logtalk's syntax is based on Prolog:

?- write, nl.
Hello world
true.

Defining an object:

:- initialization.
:- public.
p1 :- write, nl.
:- private.
p2 :- write, nl.

Using the object, assuming is saved in a my_first_object.lgt file:

?- logtalk_load.
Hello world
true.
?- my_first_object::p1.
This is a public predicate
true.

Trying to access the private predicate gives an error:

?- my_first_object::p2.
ERROR: error

Prolog back-end compatibility

As of October 2016, supported back-end Prolog compilers include B-Prolog, , ECLiPSe, GNU Prolog, JIProlog,
, , , SICStus Prolog, SWI-Prolog, XSB, and YAP. Logtalk allows use of back-end Prolog compiler libraries from within object and categories.

Developer tools

Logtalk features on-line help, a documenting tool, an entity diagram generator tool, a built-in debugger, a unit test framework with code coverage analysis, and is also compatible with selected back-end Prolog profilers and graphical tracers.

Applications

Logtalk has been used to process STEP data models used to exchange product manufacturing information. It has also been used to implement a reasoning system that allows preference reasoning and constraint solving.