Logtalk
Encyclopedia
Logtalk is an object-oriented
Object-oriented programming
Object-oriented programming is a programming paradigm using "objects" – data structures consisting of data fields and methods together with their interactions – to design applications and computer programs. Programming techniques may include features such as data abstraction,...

 logic programming
Logic programming
Logic programming is, in its broadest sense, the use of mathematical logic for computer programming. In this view of logic programming, which can be traced at least as far back as John McCarthy's [1958] advice-taker proposal, logic is used as a purely declarative representation language, and a...

 language that extends the Prolog
Prolog
Prolog is a general purpose logic programming language associated with artificial intelligence and computational linguistics.Prolog has its roots in first-order logic, a formal logic, and unlike many other programming languages, Prolog is declarative: the program logic is expressed in terms of...

 language with a feature set suitable for programming in the large
Programming in the large
In software development, programming in the large and programming in the small describe two different approaches to writing software. The terms were coined by Frank DeRemer and Hans Kron in their 1975 paper "Programming-in-the large versus programming-in-the-small" Fred Brooks identifies that the...

. It provides support for encapsulation and data hiding
Information hiding
In computer science, information hiding is the principle of segregation of the design decisions in a computer program that are most likely to change, thus protecting other parts of the program from extensive modification if the design decision is changed...

, separation of concerns
Separation of concerns
In computer science, separation of concerns is the process of separating a computer program into distinct features that overlap in functionality as little as possible. A concern is any piece of interest or focus in a program. Typically, concerns are synonymous with features or behaviors...

 and enhanced code reuse
Code reuse
Code reuse, also called software reuse, is the use of existing software, or software knowledge, to build new software.-Overview:Ad hoc code reuse has been practiced from the earliest days of programming. Programmers have always reused sections of code, templates, functions, and procedures...

. Logtalk uses standard Prolog syntax with the addition of a few operators and directives.

Logtalk is distributed under an open source
Open source
The term open source describes practices in production and development that promote access to the end product's source materials. Some consider open source a philosophy, others consider it a pragmatic methodology...

 license and can run using ISO-compliant Prolog implementations 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
Class (computer science)
In object-oriented programming, a class is a construct that is used as a blueprint to create instances of itself – referred to as class instances, class objects, instance objects or simply objects. A class defines constituent members which enable these class instances to have state and behavior...

 (with optional metaclass
Metaclass
In object-oriented programming, a metaclass is a class whose instances are classes. Just as an ordinary class defines the behavior of certain objects, a metaclass defines the behavior of certain classes and their instances. Not all object-oriented programming languages support metaclasses...

es) and prototypes, parametric objects, protocols
Protocol (object-oriented programming)
In object-oriented programming, a protocol or interface is a common means for unrelated objects to communicate with each other. These are definitions of methods and values which the objects agree upon in order to cooperate....

 (interfaces), categories (mixin
Mixin
In object-oriented programming languages, a mixin is a class that provides a certain functionality to be inherited or just reused by a subclass, while not meant for instantiation , Mixins are synonymous functionally with abstract base classes...

s, aspects
Aspect-oriented programming
In computing, aspect-oriented programming is a programming paradigm which aims to increase modularity by allowing the separation of cross-cutting concerns...

), multiple inheritance
Multiple inheritance
Multiple inheritance is a feature of some object-oriented computer programming languages in which a class can inherit behaviors and features from more than one superclass....

, event-driven programming
Event-driven programming
In computer programming, event-driven programming or event-based programming is a programming paradigm in which the flow of the program is determined by events—i.e., sensor outputs or user actions or messages from other programs or threads.Event-driven programming can also be defined as an...

, high-level multi-threading programming, reflection
Reflection (computer science)
In computer science, reflection is the process by which a computer program can observe and modify its own structure and behavior at runtime....

, and automatic generation of documentation.

For Prolog programmers, Logtalk provides predicate namespace
Namespace
In general, a namespace is a container that provides context for the identifiers it holds, and allows the disambiguation of homonym identifiers residing in different namespaces....

s (supporting both static and dynamic objects), private, protected, and public object predicates, coinductive predicates
Coinduction
In computer science, coinduction is a technique for defining and proving properties of systems of concurrent interacting objects.Coinduction is the mathematical dual to structural induction...

, separation between interface and implementation, better portability than Prolog modules, simple and intuitive meta-predicate semantics, and lambda expressions
Lambda calculus
In mathematical logic and computer science, lambda calculus, also written as λ-calculus, is a formal system for function definition, function application and recursion. The portion of lambda calculus relevant to computation is now called the untyped lambda calculus...

.

Examples

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

As of October 2011, supported back-end Prolog compilers include B-Prolog
BProlog
B-Prolog is a high-performance implementation of the standard Prolog language with several extended features including matching clauses, action rules for event handling, finite-domain constraint solving, arrays and hash tables, declarative loops, and tabling. First released in 1994, B-Prolog is now...

, CxProlog, ECLiPSe
ECLiPSe
ECLiPSe is a software system for the development and deployment of Constraint Programming applications, e.g. in the areas of optimization, planning, scheduling, resource allocation, timetabling, transport etc....

, GNU Prolog
GNU Prolog
GNU Prolog is a compiler developed by with an interactive debugging environment for Prolog available for Unix, Windows and Mac OS X...

, LeanProlog, Qu-Prolog, SICStus Prolog, SWI-Prolog
SWI-Prolog
SWI-Prolog is an open source implementation of the programming language Prolog, commonly used for teaching and semantic web applications.It has a rich set of features, libraries forconstraint logic programming,multithreading,unit testing,GUI,...

, XSB
XSB
XSB is the name of a dialect of the Prolog programming language and its implementation developed at Stony Brook University in collaboration with the Katholieke Universiteit Leuven, the New University of Lisbon, Uppsala University and software vendor XSB, Inc....

, and YAP Prolog
YAP Prolog
YAP is an open source, high-performance implementation of the Prolog programming language developed at LIACC/Universidade do Porto and at COPPE Sistemas/UFRJ. Its Prolog engine is based in the WAM , with several optimizations for better performance...

. Logtalk allows seamless use of the back-end Prolog compiler libraries from within object and categories.

Developer tools

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.

Applications

Logtalk has been used to process STEP
ISO 10303-21
STEP-File is the most widely used data exchange form of STEP. Due to its ASCII structure it is easy to read with typically one instance per line. The format of a STEP-File is defined in ISO 10303-21 Clear Text Encoding of the Exchange Structure....

 data models used to exchange product manufacturing information
Product Manufacturing Information
Product and manufacturing information, also abbreviated PMI, conveys non-geometric attributes in 3D computer-aided design and Collaborative Product Development systems necessary for manufacturing product components or subsystems. PMI may include geometric dimensions and tolerances, 3D...

. It has also been used to implement a reasoning system that allows preference reasoning and constraint solving.

See also

  • Mercury (programming language)
  • Oz (programming language)
    Oz (programming language)
    Oz is a multiparadigm programming language, developed in the Programming Systems Lab at Université catholique de Louvain, for programming language education. It has a canonical textbook: Concepts, Techniques, and Models of Computer Programming....

  • Prolog++
    Prolog++
    Prolog++ is an object-oriented toolkit for the Prolog logic programming language. It allows classes and class hierarchies to be created within Prolog programs....

  • Visual Prolog
    Visual Prolog
    Visual Prolog, also formerly known as PDC Prolog and Turbo Prolog, is a strongly typed object-oriented extension of Prolog. As Turbo Prolog it was marketed by Borland, but it is now developed and marketed by the Danish firm Prolog Development Center that originally developed it...


External links

  • P. Moura, creator's site
  • 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)
The source of this article is wikipedia, the free encyclopedia.  The text of this article is licensed under the GFDL.
 
x
OK