Re: dynamic programming

"Richard A. O'Keefe" <[email protected]>
Newsgroups gmane.comp.ai.prolog.swi
Message-ID <[email protected]>
On 2/09/2013, at 5:32 AM, Kilián Imre wrote:

> Hi Jan!
> 
> 
> In my project (modal semantic web) I am using the dynamic programming ability of SWI Prolog pretty extensively. I am constructing and querying Prolog objects, modules, predicates etc. by another Prolog program.
> 
> 1. One remark, that the whole stuff is a little bit clumsy or at least incoherent, that would well need a restructuring and maybe standardizing (among Prolog versions)... What is your opinion?
> 
> 2. My problem is the following:
> 
> if I add a new clause from a module x to a dynamic module, let say:
> 
> assert((a:b:-c)).

You should be writing assert(a:(b :- c)).
Some people prefer a:assert((b :- c)).
> 
> I have several problems with this result, but first of all I want to ask, if it is a feature, or a mistake?

It is *your* mistake.  You are doing it wrong.

> In my opinion the implementation of assert should notice, if right hand calls are made to the same module where the clause is placed (in our case 'a'),

You are asking for the impossible.  For one thing,
when you write assert((a:b :- c)) you are *specifying* that
the right hand calls are *NOT* made to the module 'a'.

> and optimize eventual chained ":" operators out...

If any Prolog system sees a:x:c as a goal, it is at liberty
to generate whatever executable code it likes as like as it
has the same effect, just as seeing X is 1 + 1 it is allowed
to compile code for X is 2.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.