Visual Prolog
From Wikipedia, the free encyclopedia
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 (PDC) that originally developed it. Visual Prolog can build Microsoft Windows GUI-applications, console applications, dll's and CGI-programs. It can also link to COM components, and to databases by means of ODBC.
Visual Prolog is compiled rather than interpreted, as is traditional for logic languages. This provides for an execution speed comparable to C++, and the important improvement of converting traditional prolog-typical runtime-errors to compiler errors, which offers a much better stability of the finished applications.
The core of Visual Prolog are Horn clauses, pattern matching and controlled non-determinism like in traditional Prolog, but unlike traditional Prolog, Visual Prolog has always been strongly and statically typed. Since version 6.0 the language has been fully object-oriented, and in version 7.0 parametric polymorphism was introduced.
In the 'Towers of Hanoi' example, the Prolog inference engine figures out how to move a stack of any number (not only 8!) of progressively smaller disks from the left ('left') pole to the right pole ('right') in the most effective way, by means of a center ('center') pole as transit, so that there's never a bigger disk on top of a smaller disk. The predicate 'hanoi' takes an integer = the number of disks, as an initial argument. In real-life, Visual Prolog is especially suited for intricate problems, such as resource planning, etc. As the example shows, Visual prolog can be used for quick 'programming in the small,' but it is mostly employed for industrial-strength large applications.
[edit] Hanoi Example
class hanoi predicates hanoi : (unsigned N). end class hanoi implement hanoi domains pole = string. clauses hanoi(N) :- move(N, "left", "centre", "right"). class predicates move : (unsigned N, pole A, pole B, pole C). clauses move(0, _, _, _) :- !. move(N, A, B, C) :- move(N-1, A, C, B), stdio::writef("move a disc from % pole to the % pole\n", A, B), move(N-1, C, B, A). end implement hanoi goal console::init(), hanoi::hanoi(4).
[edit] External links
[edit] See also
Preceding: | Prolog |
Subsequent: | none |
Categories: Articles with example Visual Prolog code | Class-based programming languages | Concurrent programming languages | Debuggers | Free compilers and interpreters | Integrated development environments | Multi-paradigm programming languages | Object-oriented programming languages | Prolog Compilers | Prolog programming language family | Statically-typed programming languages