Logtalk aims to bring together the advantages of object-oriented programming and logic programming.4 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 (with optional metaclasses) and prototypes, parametric objects,5 protocols (interfaces), categories (components, aspects, hot patching), multiple inheritance, public/protected/private inheritance, event-driven programming, high-level multi-threading programming,6 reflection, and automatic generation of documentation.
For Prolog programmers, Logtalk provides wide portability, featuring predicate namespaces (supporting both static and dynamic objects), 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 (internally, modules are compiled as prototypes).
Logtalk's syntax is based on Prolog:
Defining an object:
Using the object, assuming is saved in a my_first_object.lgt file:
Trying to access the private predicate gives an error:
This section is an excerpt from Examples of anonymous functions § Logtalk.[edit]
Logtalk uses the following syntax for anonymous predicates (lambda expressions):
A simple example with no free variables and using a list mapping predicate is:
Currying is also supported. The above example can be written as:
Supported back-end Prolog compilers include B-Prolog, Ciao Prolog, CxProlog, ECLiPSe, GNU Prolog, JIProlog, Quintus Prolog, Scryer Prolog, SICStus Prolog, SWI-Prolog, Tau Prolog, Trealla Prolog, XSB, and YAP.7 Logtalk allows use of back-end Prolog compiler libraries from within object and categories.
Logtalk features on-line help, a documenting tool (that can generate PDF and HTML files), an entity diagram generator tool, a built-in debugger (based on an extended version of the traditional Procedure Box model found on most Prolog compilers), a unit test framework with code coverage analysis, and is also compatible with selected back-end Prolog profilers and graphical tracers.8
Logtalk has been used to process STEP data models used to exchange product manufacturing information.9 It has also been used to implement a reasoning system that allows preference reasoning and constraint solving.10
Paulo Moura (2003). Logtalk: Design of an Object-Oriented Logic Programming Language. PhD thesis. Universidade da Beira Interior ↩
Moura, Paulo (2011). Programming Patterns for Logtalk Parametric Objects. Applications of Declarative Programming and Knowledge Management. Lecture Notes in Computer Science. Vol. 6547. doi:10.1007/978-3-642-20589-7_4. ISBN 978-3-642-20588-0. 978-3-642-20588-0 ↩
Practical Aspects of Declarative Languages. Lecture Notes in Computer Science. Vol. 4902. 2008. doi:10.1007/978-3-540-77442-6. ISBN 978-3-540-77441-9. 978-3-540-77441-9 ↩
"Logtalk compatibility". Logtalk.org. 2016-10-10. Retrieved 2021-07-06. https://logtalk.org/compatibility.html ↩
"Developer Tools – LogtalkDotOrg/logtalk3 Wiki – GitHub". Github.com. 2013-02-12. Retrieved 2013-08-19. https://github.com/LogtalkDotOrg/logtalk3/wiki/Developer-Tools ↩
Logic Programming. Lecture Notes in Computer Science. Vol. 4079. 2006. doi:10.1007/11799573. ISBN 978-3-540-36635-5. 978-3-540-36635-5 ↩
Victor Noël; Antonis Kakas (2009). Gorgias-C: Extending Argumentation with Constraint Solving (PDF). Logic Programming and Nonmonotonic Reasoning. Lecture Notes in Computer Science. Vol. 5753. pp. 535–541. ftp://ftp.irit.fr/IRIT/SMAC/DOCUMENTS/PUBLIS/lpnmr-09_noel-kakas.pdf ↩