1

I am kind of annoyed by having to manually re-consult my prolog every time I made changes in its source file.

Can I make it run automatically somehow? I have searched for some extensions on vscode IDE, but could not come to a solution. Any ideas or scripts?

2 Answers2

1

Just say make in SWI. Similar functionality is available for SICStus.

false
  • 10,264
  • 13
  • 101
  • 209
  • https://www.swi-prolog.org/pldoc/man?predicate=make/0 is a different operation to https://www.swi-prolog.org/pldoc/man?predicate=consult/1 – brebs Aug 14 '23 at 08:19
  • 1
    @brebs it might be that OP meant the question in the way this answer approaches it – TA_intern Aug 14 '23 at 11:22
  • @brebs: when would there be a notable difference to OP? `consult/1` always consults, even if nothing changed. Is this the difference you are referring to? – false Aug 14 '23 at 15:21
  • `make` reloads (and shows code warnings for, if applicable) *all* loaded files (including e.g. `~/.config/swi-prolog/init.pl` for swi-prolog), whereas the user might only intend to reload a single file, if performing finely-grained debugging. – brebs Aug 14 '23 at 15:33
  • So `ensure_loaded/1` as defined in SICStus would be the ideal for you. That is, only reload if things changed in the meantime. – false Aug 14 '23 at 16:00
-1

As a little helper to minimize the inconvenience, could add a tiny predicate to the start of your script file, as a shortcut to call consult, e.g.:

c :-
    % Reload 'clumped2.pl' with just: c.
    consult('clumped2').

Then, to reload:

c.
brebs
  • 3,462
  • 2
  • 3
  • 12