Re: dynamic programming

Carlo Capelli <[email protected]>
Newsgroups gmane.comp.ai.prolog.swi
Message-ID <CABty9wwK_fj2+qgDMJK0xG5zY91G=T8Jk5Zhpp1s9i=QzHASBA@mail.gmail.com>
Not sure this will solve your problems (it doesn't helped with mine), but
to implement a dynamic module named  'a', you should do

 2 ?- a:assert((b:-c)).

true.


then you get


3 ?- a:listing.


:- dynamic b/0.


b :-

(c).

true.

HTH Carlo



2013/9/1 Kilián Imre <[email protected]>

> 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)).
>
> and then say listing(a:b).
>
> the result is
>
> b:-x:c.
>
> that is the c predicate is invoked from the module issuing the assert.
>
> If I insist on that the c predicate should also be called from module a,
> then invoke...
>
> assert((a:b:-a:c)).
>
> that results...
>
> b:- a:x:c.
>
> I have several problems with this result, but first of all I want to ask,
> if it is a feature, or a mistake? 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'), and optimize eventual chained ":"
> operators out...
>
> Or do you have another opinion?
>
> Is the problem clear?
>
>
> yours:
>
> --
> Kilián Imre/Univ.Pécs Informatics
> <[email protected]>
> _______________________________________________
> SWI-Prolog mailing list
> [email protected]
> https://lists.iai.uni-bonn.de/mailman/listinfo.cgi/swi-prolog
>
-------------- next part --------------
HTML attachment scrubbed and removed
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.