Running multiple swipl. Any suggestions on quick and easy way distinguish them?

Running two instances of swipl on Windows 10 at the same time. One has the original code that works and the other I am using with modified code.

Since the test are identical and predicates are almost identical running a test in the wrong instance can sometimes cause a loss of time because I mistakenly believe a modified predicate passed a test and in fact did not because I ran the test in the wrong instance.

So my quick and simple way to resolve this was to add a this/1 fact to each source code file.

?- this(X).
X = original.
?- this(X).
Correct to: "a_module:this(X)"? yes
X = modifying.

Other ideas I looked at to see if they already existed were

  1. A Prolog flag expecting something to identify the source code file name.
  2. A command line option that would modify the Windows title bar running swipl, but in doing a summary skim of the documentation did not see anything that could work, but could have missed something.
  3. Changing the background color.

The solution that would be nicest is to just have the name of the file or the value of this/1 automatically added to the title bar.

Any one else doing something quick and easy to distinguish multiple instances of swipl?


The current way I start swipl is by clicking on an icon in the task bar which invokes

"C:\Program Files\swipl\bin\swipl-win.exe" --win_app

With the task bar icon multiple instances can be started but they all start with the same command and thus create the same title bar.


EDIT

Using window_title/2 as noted by Jan and using window_title/2 as a directive

:- window_title(_,'Original').

will automatically set the title when the code is loaded.


Is the original code and the modified code each wrapped in its own single module?

No, but there is no reason it can not be.

Let’s assume you have a pristine.pl Prolog file defining a pristine module with the working code and a modified.pl Prolog file defining a modified module with the modified code. You can load both without conflict using:

?- use_module(pristine, []), use_module(modified, []).

You can switch between modules easily:

?- module(pristine).

pristine:  ?- 
...

?- module(modified).

modified:  ?- 
...

The module: ?- prompt makes it clear the context as you asked.

Assuming a common set of tests, we can apply them to both modules to compare results. You should be able to call run_tests/0 working from within each module. If not, Logtalk’s lgtunit provides an alternative. In a tests.lgt file:

:- set_logtalk_flag(hook, lgtunit).

:- object(tests(_Module_),
    extends(lgtunit)).

    :- use_module(_Module_, [
        % predicates being tested
    ]).

    % tests

:- end_object.

The lgtunit tool supports multiple test dialects, including one that should make porting your tests (I assume written using plunit) simple if not trivial. To run the tests:

?- {lgtunit(loader}, tests}.
...

?- tests(pristine)::run.
...

?- tests(modified)::run.
...

Or we can run the tests on both version of the code:

?- lgtunit::run_test_sets([tests(pristine), tests(modified)]).
...
1 Like

See window_title/2 and win_window_color/2

1 Like

window_title/2 was exactly what I needed.
window_title(-Old, +New)

?- window_title(Old,'Modifying').
Old = 'SWI-Prolog (AMD64, Multi-threaded, version 8.1.24)'.

win_window_color/2 is a nice bonus.
win_window_color(+Which, +RGB)

?- win_window_color(background,rgb(102,255,0)).
true.