Jekejeke Prolog 1.1.1 (Object-Orientation via ISO Moduls)
Jan Burse, created Jan 25. 2016
We have just uploaded the new release of Jekejeke Prolog. We were mainly adding some first built-ins for object orientation.
- Fusing Predicates & Evaluables:
There is now an automatism in place that automatically creates a bridge for primary predicates so that they can be used as evaluables, and vice versa there are automatic tunnels so that in turn these can be used as predicates. Here is an example with a predicate definition:
factorial(N, X) :- N>0, M is N-1, factorial(M, Y), X is N*Y.
Thanks to the automatic bridging the predicate can be invoked as follows:
?- X is factorial(10).
X = 3628800
Analogously there exists a predicate for the predefined evaluable cos/1 thanks to automatic tunnelling:
?- cos(0, X).
X = 1.0
The bridging and tunnelling also works for auto loaded Java classes and for the built predicates call/n.
- Anonymous Import:
There are the new predicates package/1, use_package/1 and use_file_extension/1 to safe typing work when using modules. A couple of use_package/1 and use_file_extension/1 such as foreign(java/lang), library(jekpro/frequent), .class und .p are predefined.
- Late Binding & Class Relationships:
The new built-in (::)/2 realizes a Pythonesk call of either a reference data type or a term object. The call can be either against auto loaded Java class as displayed here.
?- 'System':err(X), X::println(abc).
/* output will go somewhere else */
or against manually defined Prolog texts. The re-export directive from the module system is responsible for representing direct inheritance. Non static methods can be again defined as in Python:
:- module(point, ).
x(Self, X) :- arg(1, Self, X).
The inheritance relationship can be queried by the new predicates sys_subclass_of/2 and sys_instance_of/2.
Since our object orientation is based on the ISO module system it is easy to learn and doesn't need much extra code. Corresponding examples are still in the making.