[net.lang] Things left out of Borland's Prolog

ted@imsvax.UUCP (Ted Holden) (11/05/86)

There's a paragraph in the September issue of Dobbs Journal which I can't
get over:

    "Perhaps the greatest shortcoming of Turbo Prolog as an implementation
    of Prolog is the lack of what might be called "metalinguistic" functions
    and operators.  Some of these supplied in Prolog are arg, functor, name,
    op, clause, and call and the univ operator.  In general, these functions
    allow the Prolog program to examine itself, to operate on code as data,
    and to construct new clauses and goals undreampt of by the programmer."

Now, I don't TRUST my own computer or any of IMS's computers enough to
let them try to program themselves.... no telling what they might try
to do.   Can anyone out there give me an example of a legitimate use
for such a technique, preferably one which could not be achieved with
more ordinary kinds of programming skills and languages?   Any opinions
as to whether Kahn left these things out of Turbo Prolog because he
thought they were dangerous or whether he's just being lazy?

Ted Holden
IMS

norvell@utcsri.UUCP (Theodore S. Norvell) (11/06/86)

>     "Perhaps the greatest shortcoming of Turbo Prolog as an implementation
>     of Prolog is the lack of what might be called "metalinguistic" functions
>     and operators.  Some of these supplied in Prolog are arg, functor, name,
>     op, clause, and call and the univ operator.  In general, these functions
>     allow the Prolog program to examine itself, to operate on code as data,
>     and to construct new clauses and goals undreampt of by the programmer."
> 
> Now, I don't TRUST my own computer or any of IMS's computers enough to
> let them try to program themselves.... no telling what they might try
> to do.   Can anyone out there give me an example of a legitimate use
> for such a technique, preferably one which could not be achieved with
> more ordinary kinds of programming skills and languages?   

What is a compiler, if not a program which operates on code as data?
If you really don't trust a computer to program itself, let me (rhetoricly)
ask you this: Do you use a compiler, or do you punch hex-codes in to a front
panel?  :-)

Example: Turbo Prolog as supplied can not read definite clause grammars (DCGs).
In most Prologs this would be a minor problem, one simply writes a DCG to 
Prolog compiler.  This complier reads a DCG and translates its non-terminals
into Prolog procedures which then become part of the program.  I doubt
that this can be done in Turbo with the elegance it can be done with in
(more) standard Prologs.

Call is needed for passing procedures as parameters.  Even ``ordinary 
languages'' (Fortran, Pascal, C) support this.  Turbo doesn't.

By the way, arg, functor, name and univ are useful for manipulating all 
kinds of data, not just code.

Also missing from Turbo (I have heard) is the ability to assert rules
(as distinct from facts).

> Any opinions
> as to whether Kahn left these things out of Turbo Prolog because he
> thought they were dangerous or whether he's just being lazy?
> 
> Ted Holden
> IMS
I suspect that they were left out primarily to make the product fast.
Both at compile time (hence no operator definition) and at run time
(hence no call or (full) assert).  The absence of univ etc may to be
related to Turbo Prolog's bizarre type system.

Turbo Prolog is no doubt a good product and a real bargain.  But let the
buyer beware, it is missing many of the features which set Prolog apart 
from other languages.  It is arguably not real Prolog.  Of course not
everyone wants real Prolog because it tends to be slow.  From what I've
heard Turbo is not.
					Theodore Norvell
					DCS U of T

Reference: Clocksin & Mellish, _Programming_in_Prolog_, Springer Verlag 1981
Chapter 9 explains DCGs.  Other chapters give examples of uses of call,
assert, univ etc.

Disclaimer: I haven't used Turbo Prolog yet and would be happy to hear
that it is not as limited as I think.

rcb@rti-sel.UUCP (Random) (11/07/86)

In article <636@imsvax.UUCP> ted@imsvax.UUCP (Ted Holden) writes:
>
>
>There's a paragraph in the September issue of Dobbs Journal which I can't
>get over:
>
>    "Perhaps the greatest shortcoming of Turbo Prolog as an implementation
>    of Prolog is the lack of what might be called "metalinguistic" functions
>    and operators.  Some of these supplied in Prolog are arg, functor, name,
>    op, clause, and call and the univ operator.  In general, these functions
>    allow the Prolog program to examine itself, to operate on code as data,
>    and to construct new clauses and goals undreampt of by the programmer."
>
>Now, I don't TRUST my own computer or any of IMS's computers enough to
>let them try to program themselves.... no telling what they might try
>to do.   Can anyone out there give me an example of a legitimate use
>for such a technique, preferably one which could not be achieved with
>more ordinary kinds of programming skills and languages?   Any opinions
>as to whether Kahn left these things out of Turbo Prolog because he
>thought they were dangerous or whether he's just being lazy?
>
>Ted Holden
>IMS

I once wrote a program that parsed english sentences. If the sentence
was a statement of fact like "John likes computers" it would
be parsed into 
	
	likes(john, computers).

A statement like "If john likes computers, then john uses computers" would
become:

	uses(john, computers) :- likes(john, computers).

The a question like "Does john use computers" would become:

	:- uses(john, computers)

The program would build these pices of code and then execute them. The base
code was very simple but a lot could be done once the information had been
fed into it.
-- 
					Random (Randy Buckland)
					Research Triangle Institute
					...!mcnc!rti-sel!rcb