4 Built-in Predicates
AllApplicationManualNameSummaryHelp

  • Documentation
    • Reference manual
      • Built-in Predicates
        • Notation of Predicate Descriptions
        • Character representation
        • Loading Prolog source files
        • Editor Interface
        • List the program, predicates or clauses
          • listing/1
          • listing/0
          • portray_clause/1
          • portray_clause/2
        • Verify Type of a Term
        • Comparison and Unification of Terms
        • Control Predicates
        • Meta-Call Predicates
        • Delimited continuations
        • Exception handling
        • Handling signals
        • DCG Grammar rules
        • Database
        • Declaring predicate properties
        • Examining the program
        • Input and output
        • Status of streams
        • Primitive character I/O
        • Term reading and writing
        • Analysing and Constructing Terms
        • Analysing and Constructing Atoms
        • Localization (locale) support
        • Character properties
        • Operators
        • Character Conversion
        • Arithmetic
        • Misc arithmetic support predicates
        • Built-in list operations
        • Finding all Solutions to a Goal
        • Forall
        • Formatted Write
        • Global variables
        • Terminal Control
        • Operating System Interaction
        • File System Interaction
        • User Top-level Manipulation
        • Creating a Protocol of the User Interaction
        • Debugging and Tracing Programs
        • Obtaining Runtime Statistics
        • Execution profiling
        • Memory Management
        • Windows DDE interface
        • Miscellaneous
    • Packages

4.5 List the program, predicates or clauses

listing(:Pred)
List predicates specified by Pred. Pred may be a predicate name (atom), which lists all predicates with this name, regardless of their arity. It can also be a predicate indicator (<name>/<arity> or <name>//<arity>), possibly qualified with a module. For example: ?- listing(lists:member/2)..

A listing is produced by enumerating the clauses of the predicate using clause/2 and printing each clause using portray_clause/1. This implies that the variable names are generated (A, B, ... ) and the layout is defined by rules in portray_clause/1.

listing
List all predicates from the calling module using listing/1. For example, ?- listing. lists clauses in the default user module and ?- lists:listing. lists the clauses in the module lists.
portray_clause(+Clause)
Pretty print a clause. A clause should be specified as a term `<Head> :- <Body>'. Facts are represented as `<Head> :- true' or simply <Head>. Variables in the clause are written as A, B, ... . Singleton variables are written as _. See also portray_clause/2.
portray_clause(+Stream, +Clause)
Pretty print a clause to Stream. See portray_clause/1 for details.