users-prolog
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: reset in gprolog


From: Daniel Diaz
Subject: Re: reset in gprolog
Date: Mon, 15 Mar 2004 12:31:57 +0100
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.6) Gecko/20040116

Hi,

there is no reset in GNU Prolog, each predicate loaded by consult erase an existing definition (if any). You can use an undocumented predicate to remove a predicate '$remove_predicate'(Pred, Arity). Here is a possible definition for reset:

reset :-
        (   current_predicate(P/N),
            '$remove_predicate'(P, N),
            fail
        ;
            true).

Obviously, if you consult this definition it will be also removed when you use reset. You can compile a file called mygprolog.pl with only this definition:

% file mygprolog.pl
:- built_in.

reset :-
        (   current_predicate(P/N),
            '$remove_predicate'(P, N),
            fail
        ;
            true).

then compile it with:

gplc myprolog.pl

lauching mygprolog you obtain a new top-level with reset as a new built-in.

Hope this helps.

Harendra Narayan wrote:
Hi,

I am trying to use 'reset' in gprolog interactive environment, but I am not able to use it. What is the way to use it ?

The basic purpose is as follows:
I use "consult('test.prolog')." to read from a prolog file. Now I modified the file and want to read it again, but before that I want to reset the prolog environment as if it has just started (i.e. only the inbuilt predicates are available). I think reset is the one which will serve this purpose but I am not able to use it. I always get "uncaught exception:error...".

Thanks in advance for the help.
Harendra

--
===============================================
                 Daniel Diaz
University of Paris 1      INRIA Rocquencourt
75013 Paris FRANCE      78153 Le Chesnay FRANCE
        web: http://pauillac.inria.fr/~diaz
        email: address@hidden

--
Ce message a subi une analyse antivirus par MailScanner ; il est vraisemblablement
sans danger.





reply via email to

[Prev in Thread] Current Thread [Next in Thread]