« Return to Thread: Inconsistent behaviour of assert/2

Re: Inconsistent behaviour of assert/2

by Richard O'Keefe :: Rate this Message:

Reply to Author | View in Thread

Why isn't there an assert(Head, Body)
to mirror clause(Head, Body)?

Because there is an assert(+Clause, -DbRef) in DEC-10
Prolog, an (almost unusable)
assert(+Clause, +Integer_Position) in Arity Prolog,
and so on.

Of course, that's no explanation of why there isn't
a command with the same interface and effect but a
different name.  I guess the answer is that nobody
ever wanted one all that badly:

        my_assert(Head, Body) :-
            assert(( Head :- Body )).

will do the job.  The absence of

        retract(Head, Body) :-
            clause(Head, Body, DbRef),
            erase(DbRef).

is much more of a nuisance, but given clause/3 and erase/3
not _that_ much of a nuisance.  That one _could_ be added
without too much pain.

On Jun 29, 2009, at 12:41 PM, Ulrich Neumerkel wrote:
> There are more fundamental problems with Prolog's term representation.
> In particular the defaulty role of control constructs like (',')/2
> which makes writing meta-interpreters and other meta-programs
> unnecessarily complex and impure.

Agreed.
>
>
> The original representation of Prolog programs, using a prefix + for
> heads and - for goals led itself more naturally to a clean
> representation.

Edinburgh used that syntax for a while, but switched over
to the Prolog syntax we now know for several reasons, top
among them readability.  It is worth noting that the
"defaulty" representation was NEVER the actual internal
representation in DEC-10 Prolog or Quintus Prolog:
assert/1 always converted it to something much more convenient
for interpretation.
>
>
> It is often preferable to transform clauses into a more appropriate
> representation.

100% agreement on that.  In fact I've come across very few
input representations, in Prolog or Lisp, that should NOT
be transformed to something else for processing.

_______________________________________________
SWI-Prolog mailing list
SWI-Prolog@...
https://mailbox.iai.uni-bonn.de/mailman/listinfo.cgi/swi-prolog

 « Return to Thread: Inconsistent behaviour of assert/2