Re: [eclipse-users] Reloading a file with dynamic predicates

From: Paulo Moura <pmoura_at_...16...>
Date: Wed, 18 Apr 2007 17:41:26 +0100
Hi Joachim Schimpf!

> Paulo Moura wrote:
>> Hi Kish!
>>
>>> For dynamic predicates, you can retract them before adding new
>>> ones. If you use retract_all/1,
>>> you can remove all the definitions of the predicate:
>>> ...
>>
>> That's not really a feasible solution. It would imply finding which
>> dynamic predicates are declared and which dynamic predicates are
>> defined in a file (before reloading it) in order to use, as you
>> suggest, retract_all/1 or abolish/1. It would be possible/easy to
>> modify the behavior of compile/1 to match the behavior of most Prolog
>> compilers when reloading a file? I.e. to "reset" the dynamic
>> predicates with the original file definitions, as already done for
>> static predicates?
>
> Assigning such a significance to the *file* that a clause comes from
> is really quite an irregular feature (clauses, especially dynamic  
> ones,
> don't always come from files, they may come from a socket, string,  
> list,
> tty, assert - what to do in these cases?).  It is a relic from the  
> times
> before there were module systems.
>
> The problem doesn't exist with modules - when reloading a module, any
> old module content gets erased, including dynamic predicates.

The same is done when reloading (Logtalk) objects. Except when  
running under ECLiPSe using the lib(iso) library :(

> Another clean solution (in native ECLiPSe mode) is to put a :- dynamic
> directive at the top of your file.

Already there. So, the problem is that it only works in native  
ECLiPSe mode, and not when using the lib(iso), as you write below.

> This will reinitialise the dynamic
> predicate if it exists already.  Unfortunately, the ISO standard  
> decided
> to define dynamic/1 differently, so this isn't supported in lib(iso)
> mode (which Paulo is probably using).

Correct. I'm not aware of the conflict between the behavior I'm  
asking for the ISO Prolog standard. I've the standard at home; I will  
check it later. Thanks for the tip.

All the best,

Paulo


-----------------------------------------------------------------
Paulo Jorge Lopes de Moura
Dep. of Computer Science, University of Beira Interior
6201-001 Covilhã, Portugal

Office 4.3  Ext. 3257
Phone: +351 275319891 Fax: +351 275319899
Email: <mailto:pmoura_at_...16...>

Home page: <http://www.di.ubi.pt/~pmoura>
Research: <http://logtalk.org/>
-----------------------------------------------------------------
Received on Wed Apr 18 2007 - 17:42:04 CEST

This archive was generated by hypermail 2.3.0 : Wed Sep 25 2024 - 15:13:20 CEST