2.1 Getting started quickly
AllApplicationManualNameSummaryHelp

  • Documentation
    • Reference manual
      • Overview
        • Getting started quickly
          • Starting SWI-Prolog
          • Adding rules from the console
          • Executing a query
          • Examining and modifying your program
          • Stopping Prolog
    • Packages

2.1.4 Examining and modifying your program

If properly configured, the predicate edit/1 starts the built-in or user configured editor on the argument. The argument can be anything that can be linked to a location: a file name, predicate name, module name, etc. If the argument resolves to only one location the editor is started on this location, otherwise the user is presented a choice.

If a graphical user interface is available, the editor normally creates a new window and the system prompts for the next command. The user may edit the source file, save it and run make/0 to update any modified source file. If the editor cannot be opened in a window, it opens in the same console and leaving the editor runs make/0 to reload any source files that have been modified.

?- edit(likes).

true.
?- make.
% /home/jan/src/pl-devel/linux/likes compiled 0.00 sec, 0 clauses

?- likes(sam, X).
...

The program can also be decompiled using listing/1 as below. The argument of listing/1 is just a predicate name, a predicate indicator of the form Name/Arity, e.g., ?- listing(mild/1). or a head, e.g., ?- listing(likes(sam, _))., listing all matching clauses. The predicate listing/0, i.e., without arguments lists the entire program.9This lists several hook predicates that are defined by default and is typically not very informative.

?- listing(mild).
mild(dahl).
mild(tandoori).
mild(kurma).

true.