The programmer does not have to wait till the program is actually executed to detect a bug. Therefore, when Visual Prolog performs a compilation, it checks the program quite thoroughly to weed out such grammatical and other mistakes.īecause of this feature in Visual Prolog, the overall efficiency of a programmer improves. When you declare the predicates and domains in advance, this kind of positional grammar (which argument belongs to which domain), etc. For example, if you had intended to use an integer as the argument of a functor, and instead of the integer you had erroneously used a real number, it would become a runtime error in programs written using most other Prolog compilers and the program would fail there. The reason such forewarnings are required in Visual Prolog is to ensure that runtime exceptions are converted into compile time errors as far as possible.īy "runtime exceptions", we mean issues that turn up when a program is run. Similarly, before using any domains, they need to be declared.
#Visual prolog 5.2 tutorial code#
However, in Visual Prolog, before writing the code for the clause body of a predicate we first need to declare the existence of such a predicate. We simply use a domain the moment we feel the need for it. Similarly, when a compound domain is used in traditional Prolog, we can use it without first warning the Prolog engine about our intention to use the domain. We did not bother to inform the engine in the code that such a predicate construction is to be expected later. For example, in the earlier tutorial the grandFather predicate's clause was directly written using the traditional Prolog predicate head and body construction. In Prolog, when we need to use a predicate we simply do so without any prior indication to the Prolog engine about our intention. Program Structure Differences Declarations and Definitions
#Visual prolog 5.2 tutorial how to#
It essentially comprises of understanding how to mark out the declarations from the definitions, and to indicate the main Goal that the program has to seek using specific keywords.