On 2011-10-09, bart demoen <
bart....@cs.kuleuven.be> wrote:
> On Sat, 08 Oct 2011 14:32:53 -0700, gerald.britton wrote:
>
>> Is there a Prolog compiler written in Prolog? If so, where can I get
>> it? If not, why not?
>
> Apart from ECLiPSe, also XSB, GNU-Prolog, Ciao, jProlog and hProlog have a
> compiler written in Prolog: they are all available on the net.
> (and there might be others)
> B-Prolog's compiler is written in B-Prolog AFAIK, the SICStus Prolog
> compiler is written in SICStus Prolog - not available for free.
Just wondering, which systems compile dynamic code in (practically) the
same way as static code? I can say that SWI-Prolog does this. Its
compiler is written in C. I'm not sure what I would use if I had to make
this decision again. Pattern-matching is surely a lot more practical in
Prolog. On the other hand, keeping track of annotations about variables
(allocation, initialisation status, etc.) is typically easier and more
compact in C because we can play destructively with extra-Prolog bits
and pieces of the representation.
Possibly this tells us that compiling dynamic clauses is easier in C
because we might have to deal with very large structures with huge
amounts of variables where space requirements for the variable
annotations becomes crucial and optimization is rather unimportant. On
the other hand, compiling static code might be better in Prolog because
optimization by recognising patterns is easier.
As far as I recall, my original motivation for SWI-Prolog was that the
compiler was simple anyway and that writing it in C would provide faster
assert and make bootstrapping the system easy.
Cheers --- Jan