C++ implementation of Prolog interpreter

C++ implementation of Prolog interpreter

Post by pete_abe » Wed, 26 Nov 2003 02:40:47


I tried to look for C++ sourcecode of an implementation of a Prolog
interpreter on the internet but I couldnt find any. Do you know where
I can find that?

Your help is most appreciated. Thank you

C++ implementation of Prolog interpreter

Post by Bart Demoe » Fri, 28 Nov 2003 05:09:21

If C is also fine, try google for
and find free sources, but I warn you, it is not for the weak of heart :-)


Bart Demoen


C++ implementation of Prolog interpreter

Post by pete_abe » Tue, 02 Dec 2003 22:58:04

Thank you very much, yet I was hoping to find sourcecode written in
C++. Again thank you.


C++ implementation of Prolog interpreter

Post by Jan Wielem » Tue, 02 Dec 2003 23:28:25

What for? SWI-Prolog (and most likely some of the others mentioned)
comes with a C++ header file that embeds the SWI-Prolog kernel in a
number of lightweight classes, providing efficient and quite natural
access from C++. Actually there are two, one fairly straightforward
and one that fits in nicely with C++ standard templates.

If you just want to *use* Prolog from C++ this is much better as there
are no issues with C++ name-mangling incompatibilities because the
wrapper consists entirely of inlined classes.

Or do you want to use the system as a starting point for a derived
system and you want to program in C++? I'm not convinced C++ is a
very suitable language for doing this. The fact that most Prolog
systems are written in C provides some support for this, though the
real argument for many of them is that development started before C++
was reasonable stable (or even existed). A *clean* and *efficient*
C++ design of the virtual machine with its stack management is a
challenging task. Using C++ to deal with type conversion and some
management problems as provided by the mentioned wrapper could have
made the source more compact and cleaner for the definition of the
(especially not time critical) built-in foreign predicates.

--- Jan