Logtalk

From Wikipedia, the free encyclopedia
Jump to: navigation, search
Logtalk
Paradigm(s) Logic programming
Appeared in 1998
Designed by Paulo Moura
Stable release 2.44.1 (May 28, 2012 (2012-05-28))
Preview release 3.00.0 Alpha 17 (May 20, 2013 (2013-05-20))
Influenced by Prolog, Smalltalk, Objective-C; logic programming, object-oriented programming, prototype-based programming
OS Cross-platform
License Artistic License 2.0 (2.x) / GNU GPL v3 (3.x)

Logtalk is an object-oriented logic programming language that extends the Prolog language with a feature set suitable for programming in the large.[1] It provides support for encapsulation and data hiding, separation of concerns and enhanced code reuse.[1] Logtalk uses standard Prolog syntax with the addition of a few operators and directives.

Logtalk is distributed under an open source license and can run using ISO-compliant Prolog implementations as the back-end compiler.

Contents

Features [edit]

Logtalk aims to bring together the advantages of object-oriented programming and logic programming.[1] 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,[2] protocols (interfaces), categories (mixins, aspects, hot patching), multiple inheritance, event-driven programming, high-level multi-threading programming,[3] reflection, and automatic generation of documentation.

For Prolog programmers, Logtalk provides predicate namespaces (supporting both static and dynamic objects), private, protected, and public object predicates, coinductive predicates, separation between interface and implementation, better portability than Prolog modules, simple and intuitive meta-predicate semantics, and lambda expressions.

Examples [edit]

Logtalk's syntax is based on Prolog:

?- write('Hello world'), nl.
Hello world
true.

Defining an object:

:- object(my_first_object).
 
    :- public(p1/0).
    p1 :- write('This is a public predicate'), nl.
 
    :- private(p2/0).
    p2 :- write('This is a private predicate'), nl.
 
:- end_object.

Using the object:

?- 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(permission_error(access, private_predicate, p2), my_first_object::p2, user)

Prolog back-end compatibility [edit]

As of October 2011, supported back-end Prolog compilers include B-Prolog, CxProlog, ECLiPSe, GNU Prolog, LeanProlog, Qu-Prolog, SICStus Prolog, SWI-Prolog, XSB, and YAP Prolog.[4] Logtalk allows seamless use of the back-end Prolog compiler libraries from within object and categories.

Developer tools [edit]

Logtalk features on-line help, 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, and is also compatible with selected back-end Prolog profilers and graphical tracers.[5]

Applications [edit]

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

See also [edit]

External links [edit]

  • Official website
  • Logtalking blog
  • From Plain Prolog to Logtalk Objects: Effective Code Encapsulation and Reuse (Invited Talk). Paulo Moura. Proceedings of the 25th International Conference on Logic Programming (ICLP), July 2009. LNCS 5649. Springer-Verlag Berlin Heidelberg". (Slides)

References [edit]

  1. ^ a b c Paulo Moura (2003). Logtalk: Design of an Object-Oriented Logic Programming Language. PhD thesis. Universidade da Beira Interior
  2. ^ doi:10.1007/978-3-642-20589-7_4
  3. ^ doi:10.1007/978-3-540-77442-6
  4. ^ http://logtalk.org/compatibility.html
  5. ^ https://github.com/LogtalkDotOrg/logtalk3/wiki/Developer-Tools
  6. ^ doi:10.1007/11799573
  7. ^ Victor Noël; Antonis Kakas (2009). "Gorgias-C: Extending Argumentation with Constraint Solving". Logic Programming and Nonmonotonic Reasoning. Lecture Notes in Computer Science 5753. pp. 535–541. doi:10.1007/978-3-642-04238-6_54.