/usr/local/lib/swipl/library/listing.pl
All Application Manual Name SummaryHelp

  • swipl
    • library
      • error.pl
      • debug.pl
      • apply.pl
      • lists.pl -- List Manipulation
      • broadcast.pl -- Event service
      • shlib.pl
      • option.pl -- Option list processing
      • thread_pool.pl -- Resource bounded thread management
      • gensym.pl
      • settings.pl -- Setting management
      • arithmetic.pl
      • main.pl
      • readutil.pl -- Read utilities
      • operators.pl
      • pairs.pl
      • prolog_source.pl
      • record.pl -- Access compound arguments by name
      • quasi_quotations.pl
      • pure_input.pl -- Pure Input from files and streams
      • solution_sequences.pl -- Modify solution sequences
      • ordsets.pl
      • random.pl -- Random numbers
      • base64.pl -- Base64 encoding and decoding
      • aggregate.pl
      • yall.pl
      • sandbox.pl -- Sandboxed Prolog code
      • apply_macros.pl -- Goal expansion rules to avoid meta-calling
      • assoc.pl -- Binary associations
      • prolog_format.pl -- Analyse format specifications
      • predicate_options.pl -- Access and analyse predicate options
      • csv.pl
      • pprint.pl
      • atom.pl
      • modules.pl -- Module utility predicates
      • occurs.pl -- Finding and counting sub-terms
      • prolog_xref.pl -- Prolog cross-referencer data collection
      • prolog_colour.pl -- Prolog syntax colouring support.
      • lazy_lists.pl
      • ugraphs.pl
      • url.pl
      • www_browser.pl -- Open a URL in the users browser
      • prolog_pack.pl -- A package manager for Prolog
      • git.pl
      • rbtrees.pl -- Red black trees
      • dif.pl
      • charsio.pl
      • prolog_stack.pl -- Examine the Prolog stack
      • edinburgh.pl
      • prolog_clause.pl
      • prolog_breakpoints.pl
      • wfs.pl -- Well Founded Semantics interface
      • dialect.pl -- Support multiple Prolog dialects
      • prolog_code.pl -- Utilities for reasoning about code
      • sort.pl
      • iostream.pl -- Utilities to deal with streams
      • dicts.pl
      • varnumbers.pl -- Utilities for numbered terms
      • base32.pl
      • codesio.pl
      • coinduction.pl -- Co-Logic Programming
      • date.pl -- Process dates and times
      • heaps.pl
      • statistics.pl -- Get information about resource usage
      • terms.pl -- Term manipulation
      • utf8.pl -- UTF-8 encoding/decoding on lists of character codes.
      • when.pl -- Conditional coroutining
      • backcomp.pl
      • prolog_debug.pl
      • ansi_term.pl -- Print decorated text to ANSI consoles
      • prolog_versions.pl -- Demand specific (Prolog) versions
      • prolog_codewalk.pl
      • listing.pl -- List programs and pretty print clauses
        • listing/0
        • listing/1
        • listing/2
        • portray_clause/1
        • portray_clause/2
        • portray_clause/3
      • prolog_metainference.pl -- Infer meta-predicate properties
      • thread.pl
      • threadutil.pl -- Interactive thread utilities
      • qsave.pl -- Save current program as a state or executable
      • zip.pl
      • files.pl
      • explain.pl -- Describe Prolog Terms
      • persistency.pl
      • writef.pl -- Old-style formatted write
      • help.pl -- Text based manual
      • prolog_history.pl -- Per-directory persistent commandline history
      • prolog_config.pl -- Provide configuration information
      • check.pl
      • ctypes.pl
      • nb_set.pl -- Non-backtrackable sets
      • increval.pl
      • tables.pl
      • oset.pl
      • prolog_autoload.pl
      • prolog_coverage.pl
      • prolog_trace.pl
      • prolog_wrap.pl
      • shell.pl
      • streams.pl
      • strings.pl
      • hashtable.pl
      • make.pl
      • quintus.pl
      • intercept.pl
      • prolog_profile.pl
      • portray_text.pl
      • system.pl
      • optparse.pl -- command line parsing
      • prolog_jiti.pl
      • edit.pl
      • fastrw.pl
 listing(:What) is det
 listing(:What, +Options) is det
List matching clauses. What is either a plain specification or a list of specifications. Plain specifications are:
  • Predicate indicator (Name/Arity or Name//Arity) Lists the indicated predicate. This also outputs relevant declarations, such as multifile/1 or dynamic/1.
  • A Head term. In this case, only clauses whose head unify with Head are listed. This is illustrated in the query below that only lists the first clause of append/3.
    ?- listing(append([], _, _)).
    lists:append([], L, L).
  • A clause reference as obtained for example from nth_clause/3.

The following options are defined:

variable_names(+How)
One of source (default) or generated. If source, for each clause that is associated to a source location the system tries to restore the original variable names. This may fail if macro expansion is not reversible or the term cannot be read due to different operator declarations. In that case variable names are generated.
source(+Bool)
If true (default false), extract the lines from the source files that produced the clauses, i.e., list the original source text rather than the decompiled clauses. Each set of contiguous clauses is preceded by a comment that indicates the file and line of origin. Clauses that cannot be related to source code are decompiled where the comment indicates the decompiled state. This is notably practical for collecting the state of multifile predicates. For example:
?- listing(file_search_path, [source(true)]).