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

**URL:** <https://swi-prolog.discourse.group/t/what-does-reload-modified-files-do-and-why-does-it-find-additional-errors/925>\
**Category:** Help!\
**Created:** [July 4, 2019, 9:40pm UTC](https://swi-prolog.discourse.group/t/what-does-reload-modified-files-do-and-why-does-it-find-additional-errors/925 "2019-07-04T21:40:09Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![prodog](https://avatars.discourse-cdn.com/v4/letter/p/57b2e6/32.png) [@prodog](https://swi-prolog.discourse.group/u/prodog)\
**Post date:** [July 4, 2019, 9:40pm UTC](https://swi-prolog.discourse.group/t/what-does-reload-modified-files-do-and-why-does-it-find-additional-errors/925/1 "2019-07-04T21:40:09Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Olopierpa](https://yyz2.discourse-cdn.com/free1/user_avatar/swi-prolog.discourse.group/olopierpa/32/6855_2.png) [@Olopierpa](https://swi-prolog.discourse.group/u/Olopierpa)\
**Post date:** [July 5, 2019, 12:24am UTC](https://swi-prolog.discourse.group/t/what-does-reload-modified-files-do-and-why-does-it-find-additional-errors/925/2 "2019-07-05T00:24:48Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![jan](https://yyz2.discourse-cdn.com/free1/user_avatar/swi-prolog.discourse.group/jan/32/4_2.png) [@jan](https://swi-prolog.discourse.group/u/jan)\
**Post date:** [July 5, 2019, 8:05am UTC](https://swi-prolog.discourse.group/t/what-does-reload-modified-files-do-and-why-does-it-find-additional-errors/925/3 "2019-07-05T08:05:37Z")

</div>

Yes. In this case there was hint though 🙂

> [@prodog](#):
>
> Most of them were warnings for undefined predicates

`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.

---

<div class="post-metadata">

**Author:** ![EricGT](https://avatars.discourse-cdn.com/v4/letter/e/f1d935/32.png) [@EricGT](https://swi-prolog.discourse.group/u/EricGT)\
**Post date:** [July 5, 2019, 10:25am UTC](https://swi-prolog.discourse.group/t/what-does-reload-modified-files-do-and-why-does-it-find-additional-errors/925/4 "2019-07-05T10:25:25Z")

</div>

> [@prodog](#):
>
> It came up with several warnings that did _not_ appear when I consulted those files as mentioned above.

Had the same problem a long time ago.

For the details on make see the [source code](https://github.com/SWI-Prolog/swipl-devel/blob/4bbfbecd32eda899b03e38e6a60054bdb493e579/library/make.pl) at GitHub.

Here is how I now use `make`.

So my typical scenario is to

1. Start SWI-Prolog
2. [Consult](https://www.swi-prolog.org/pldoc/man?predicate=consult/1) a source file which is typically a [module](https://www.swi-prolog.org/pldoc/man?section=defmodule), has [use\_module](https://www.swi-prolog.org/pldoc/man?section=import) directives and [unit test](https://www.swi-prolog.org/pldoc/doc_for?object=section(%27packages/plunit.html%27)) in the module(s) being developed.
3. [run\_tests](https://www.swi-prolog.org/pldoc/man?section=pldoc-running).

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](https://www.swi-prolog.org/pldoc/man?predicate=make/0) - 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](https://www.swi-prolog.org/pldoc/man?predicate=gtrace/0)  
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.
