Logtalk is an open source object-oriented extension to Prolog.
Logtalk is an open source object-oriented extension to the Prolog programming language. Integrating logic programming with object-oriented and event-driven programming, it is compatible with most Prolog compilers.
Logtalk supports both prototypes and classes. In addition, it supports component-based programming through category-based composition.
Here are some key features of "Logtalk":
- Separation between interface and implementation:
- Predicate directives (declarations) can be contained inside protocols (interfaces), which can be implemented by any object.
- Parametric objects:
- Object names can be compound terms containing free variables that can be used to parametrize object predicates.
- Support for both class-based and prototype-based systems:
- You may have, in the same application, class-based hierarchies (with instantiation and specialization relations) and prototype-based hierarchies (with extension relations).
- Support for multiple object hierarchies:
- No need to be constrained to a single lengthy hierarchy rooted in some generic object.
- Private, protected, and public inheritance:
- Logtalk supports private, protected, and public inheritance in a way similar to C . Moreover, any entity relation can be qualified using a scope keyword.
- Private, protected, and public object predicates:
- Set the scope of your object predicates to match your protocol design and let the runtime system enforce your choices.
- Static and dynamic objects:
- Objects can be either static or dynamic. Static objects are defined in source files which are compiled and loaded in the same way as Prolog files. Dynamic object can be either defined in source files or created at runtime.
- Static and dynamic object predicates:
- Any static object may contain both static and dynamic predicates.
- A pre-processor so we can use standard Prolog syntax:
- Logtalk uses standard Prolog syntax with the addition of a few operators and directives for a smooth learning curve.
- Event-driven programming:
- Predicates can be implicitly called when a spied event occurs, allowing programming solutions which minimize object coupling. In addition, events provide support for behavioral reflection.
- Component-based programming:
- Predicates can be encapsulated inside categories, which can be virtually imported by any object, without any code duplication and irrespective of object hierarchies. Thus, objects may be defined through composition of categories, which act as fine-grained units code of reuse.
- Multi-inheritance support:
- Logtalk supports multi-inheritance of both protocol and implementation. An object may implement several protocols and extend, specialize, or instantiate several objects. Multi-inheritance conflicts are solved implicitly by the Logtalk lookup algorithms or explicitly by using predicate directives.
- Good performance:
- Logtalk code is compiled using the same technics that you use to write efficient Prolog code. In addition, method lookups are cached by the Logtalk runtime engine, greatly improving performance. Benchmark results for some Prolog compilers are available here.
- Close integration with the ISO Prolog Standard:
- Logtalk is designed for smooth integration with any Prolog compiler that conforms or closely follows the ISO Prolog Standard.
- Compatible with most Prolog compilers:
- Logtalk interfaces with a specific Prolog compiler via a minimal configuration file making it compatible with almost any modern compiler.
- Automatic generation of XML documentation files:
- Logtalk automatically generates a documentation file in XML format for every compiled object, protocol, or category. The system includes all the necessary XSL(T) files and scripts to convert documenting files to (X)HTML and PDF.
- Logtalk runs on almost any computer with a Prolog compiler (the main development environment is an Apple PowerBook G4 running MacOS X). The interface between Logtalk and a specific Prolog compiler is accomplished via a configuration file.
- This file contains some Logtalk specific predicates and implementations for ISO Prolog standard predicates not available in the Prolog compiler.
- In writing Logtalk I have tried to follow the Prolog ISO standard whenever possible. Capabilities needed by Logtalk that are not defined in the Part I of the ISO standard are:
- access to predicate properties (dynamic, static, built_in):
- Provided that your favorite Prolog has these capabilities mentioned above, making a configuration file is very easy. The Logtalk package already includes configuration files for the most common Prolog compilers. For optimal performance, Logtalk requires that the Prolog compiler supports first-argument indexing for both static and dynamic code.
- Logtalk developement and testing is currently performed using the following Prolog compilers (in alphabetical order):
- GNU Prolog 1.2.18
- SWI Prolog 5.4.7
- YAP 4.5.7
- Because of that, these are probably your best choices for running Logtalk (providing that you are free to use one of these compilers).
- In addition, Logtalk runs with little or no modifications with the following Prolog compilers (in alphabetical order):
- ALS Prolog 3.1
- Amzi! Prolog 6.22~7.x
- BinProlog 8.x~10.x
- B-Prolog 4.0, 5.0, 6.x
- CIAO Prolog 1.10p5
- ECLiPSe 5.5~5.8
- IF/Prolog 5.x
- JIProlog 3.0.1-2
- K-Prolog 5.1.2a
- LPA MacProlog32 1.25
- LPA WinProlog32 4.0x
- MasterProlog 4.1
- Open Prolog 1.1b10
- PrologII 4.5
- QU-Prolog 6.7
- Quintus Prolog 3.3~3.5
- SICStus Prolog 3.8~3.12.x
- XSB 2.6~2.7
- Modified the message sending mechanism to call the "before" event handlers before performing the method lookup. This change should have no impact on existing code but allows some interesting applications (e.g. fail instead of throwing an exception when a message is not understood).
- More consistent handling of compiler flags between setting flag values when compiling/loading a file and when using the set_logtalk_flag/2 built-in predicate: in both cases, setting the "smart_compilation" flag on will turn off the "clean" flag and setting the "clean" flag on will turn off the "smart_compilation" flag. Also, setting the "debug" flag on will turn off both the "smart_compilation" and "clean" flags.
- Allows the soft-cut control construct, (*->)/2, when natively supported by the back-end Prolog compiler, to be used in the body of grammar rules (after a remark by Daniel Diaz while discussing GNU Prolog support for the soft-cut control construct).
- Corrected a Logtalk compiler bug when the "sou...