SWI - retract all but builtins

SWI - retract all but builtins

Post by Nickolay K » Fri, 05 Nov 2004 05:06:08


Hi all,

This is just a general question regarding workflow.

I have written a simple predicate ef/1 and put it in my .plrc. I use it
to edit and create source files with vi as my editor in a singe shell.
It reads:

ef(X) :-
edit(file(X)),
consult(X).

I usually start a single pl process and do my editing from there using
the predicate above or plain edit/1 for jumping straight to specific
clauses. Is there a way to add a predicate to this so that before
consulting the freshly edited (or created) file, all the predicates but
the built-ins get retracted?

I create many small files which often define predicates with the same
signatures (just trying things out, I am not doing any projects).

Any other suggestions on how to improve workflow are also greatly
appreciated. I will be spending a lot of time writing Prolog...

Yes, CL student if you are about to ask. :-)

Many thanks in advance,
Nicky
 
 
 

SWI - retract all but builtins

Post by Jan Wielem » Fri, 05 Nov 2004 07:31:25


I'd suggest

ef(X) :-
edit(file(X)),
make.

Anyway, reloading a file causes all predicates previously loaded from
that file to be abolished. Things asserted remain where they are, but
sensible programs either avoid dynamic predicates or provide a cleanup
hook for them.


I was more asking for a scenario where the default workflow fails.
After this we can argue whether there is a better workflow or your
workflow needs better support from the system.

Cheers --- Jan

 
 
 

SWI - retract all but builtins

Post by Nickolay K » Sat, 06 Nov 2004 06:17:30

> I was more asking for a scenario where the default workflow fails.


it does not fail per se. But I can nonetheless give you an example.

I can declare in one file that I consult:

verb --> [kick].
verb --> [taste].

And in another file some other verb predicates.

All the verbs declared in the first file remain after consulting the
second file. Any time I ask for a verb (generating, not recognizing),
the 'old' ones will still be there, even though I may only need the
'new' ones.

I am looking for a way to get rid of the old verbs so my super-duper
grammars only work with the new ones.

Nicky
 
 
 

SWI - retract all but builtins

Post by Bart Demoe » Sat, 06 Nov 2004 06:55:10


You don't get the message like

Redefined static procedure verb/4

?

So maybe you should show us explicitly the two files contents,
and the SWI session which shows clearly your problem.

Cheers

Bart Demoen
 
 
 

SWI - retract all but builtins

Post by Nickolay K » Sat, 06 Nov 2004 15:37:34

> You don't get the message like

I just tried to reproduce my mistake and sure enough the predicate gets
redefined.

Sorry for wasting everyone's time.

Nicky