rupert...@googlemail.com schrieb:
>> Why not also apply this idea to Prolog? Why need code,
>> >when we can work with structures?
> Hi Jan, A question about this:
>
> Using this approach do you end up with something
> comparable to a binary byte-code format in which
> code can be distributed? That is, can your
> structures easily be serialized into files, or
> are you distributing programs as source code?
>
> Rupert
I have the feeling here is also a misconception
at work. One reason for converting a Prolog code
into some other code than the Prolog text is for
example to solve the bootstrapping problem.
Take the following bootstrapping problem:
- You have a term reader written in Prolog.
- You have a consult command written in Prolog.
- But when you startup you Prolog you don't have
them yet ready, so you must load some other code,
for example byte code, to have the term reader
and the consult command, so that you then can
load other Prolog text (ASCII).
But if you have written the term reader anyway
in another language, for example Java, and the
consult command/intelligent loader also in an
other language, for example Java, then there is
never need for some other code, for example
byte code.
You can just go with this functionality which
you have in your Host language, for example
Java, so that you then can load other Prolog
text (ASCII).
The remaining question is only, is it fast.
Well you can measure yourself. There is hardly
any advantage by other code, for example byte
code, over Prolog text (ASCII). SWI-Prolog can
very very quickly parse and load Prolog text
(ASCII), I did some testing, it is faster than
Jekejeke Prolog Prolog text parsing.
And I consider Jekejeke Prolog text parsing
already fast. So if you are not planning to
do the byte code bootstrap stuff, there is no
need to have some other code. Actually I was
researching into the minimality of the kernel
recently. Besides have read/consult ops, you
need also to manually add some ur-predicates.
You can then quasi bootstrap also a great
part of the interpreter, for example file name
resolution etc.., need not be put into the
initial code. So you can have very large portion
of the interpreter itself also in Prolog text
(ASCII).
Bye
P.S.: Replace (ASCII) by (Unicode).