What does 'reload modified files' do and why does it find additional errors?

I’m using: SWI-Prolog version 8.0.2 on Windows 8.1.

I have a test predicate that when I run from the console, consults all the source files for my app. When I run it I don’t see any warnings.

However, today I tried the File -> Reload Modified Files menu option, because of some problems I was having while tracing. It came up with several warnings that did not appear when I consulted those files as mentioned above. Most of them were warnings for undefined predicates. They were all very important warnings that helped me fix several big errors in my app.

What does reload modified files actually do, and why does it catch errors that don’t get caught during a normal consult?

Also, under what circumstances should I run this feature and also the feature to clear the source code cache?

POSSIBLE BUG: If reload modified files does print any warnings, it leaves the input stream open so that you have to enter a period ‘.’ in the console to make it happy. Then it will show you the console window input prompt. If no warnings are printed, this problem does not occur.

Knowing which warnings you get would help A LOT in formulating a diagnosis.

Yes. In this case there was hint though :slight_smile:

Reload Modified Files runs make/0, which reloads modified files and runs list_undefined/0. Normal loading doesn’t do that. A lot of code people wnt to run has undefined predicates and cross referencing of really big programs can be quite costly.

1 Like

Had the same problem a long time ago.

For the details on make see the source code at GitHub.

Here is how I now use make.

So my typical scenario is to

  1. Start SWI-Prolog
  2. Consult a source file which is typically a module, has use_module directives and unit test in the module(s) being developed.
  3. run_tests.

Think of that as priming the pump.

Then the following development scenario is repeated many times.

  1. Edit source code. (Make new test cases as needed)
  2. make - Which is the same as File -> Reload Modified Files. This will reload the modified source files, do a few other things such as finding the errors, list warnings, and run the test cases.
  3. Go back to step 1.

If a test fails and I don’t know the root cause to fix it then the scenario changes to use gtrace.

3a. gtrace
4a. run_tests/1 on the test case that failed and identify the root cause
5. Go back to step 1.

Note: gtrace will be active the next time make is run, but gtrace is smart enough to know not to trace make when it is run.

1 Like