Re: Prolog module system



On Jun 16, 7:23 pm, "Mauro Di Nuzzo" <pico...@xxxxxxxxx> wrote:
Wow! This discussion is really charming for I am learning much (actually,
this sharpens my opinion).
...
On the other hand, when I came to Prolog as a logic programming language, I
expected a great part of such a language dealing with categories. Objects
must have a part in Prolog, but I do not believe that a "standard" oop can
improve Prolog (actually I think the contrary). Prolog is based on
predicates and unification.

For non-trivial Prolog applications, you need encapsulation and reuse
mechanisms, wence all the variations of Prolog module and object
systems developed so far.

Consider the length/2 predicate. Logtalk
definition is identical to standard prolog (I cannot see the advantage,
sorry). Instead, within my oop, I define a length/1 predicate, the actual
list (i.e. data) being stored elsewhere in the instance.

You can do the same within Logtalk and write queries such as:

| ?- [1, 2, 3]::length(L).

L = 3
yes

See the "examples/parametric" example.

But consider now
what definition one could use for append/3 (unless using 3 different
predicates). [I hope I expressed myself in the latter point]. So, if data
must remain into the predicate (as an argument), why oop?

Code (i.e. predicates) encapsulation and reuse.

All the best,

Paulo

.



Relevant Pages

  • Re: OO versus RDB
    ... There is a very simple mapping from RM to PROLOG. ... a representation based on predicates, ... 'connection' comes from the fact that PROLOG stores rules about facts ...
    (comp.object)
  • Re: OO versus RDB
    ... There is a very simple mapping from RM to PROLOG. ... store knowledge using predicates. ... applied to a physical representation of a relational model. ...
    (comp.object)
  • Re: Prolog, memory management and memory leaks
    ... It depends on what you mean by a memory leak. ... Did the programmer mess up, ... the Prolog implementation you are working with). ... non-deterministic predicates in not always perfect. ...
    (comp.lang.prolog)
  • Re: Cross-Compiler development (MasterProlog/SWI/SICStus)
    ... In most Prolog applications, there are usually a small set of ... top predicates and a bigger number of auxiliary predicates. ... of the object encapsulating them. ... the configuration file for your Prolog compiler, ...
    (comp.lang.prolog)
  • Re: What should the semantics of hierarchical modules be?
    ... > Brian Hulley wrote: ... >>>the pure Prolog. ... But Prolog) Predicates are global and there are no objects or types to ... and write "foo" and let prolog discover what I meant by searching" ...
    (comp.lang.prolog)