## 2.11 Environment Control (Prolog flags)

The predicates current_prolog_flag/2 and set_prolog_flag/2 allow the user to examine and modify the execution environment. It provides access to whether optional features are available on this version, operating system, foreign code environment, command line arguments, version, as well as runtime flags to control the runtime behaviour of certain predicates to achieve compatibility with other Prolog environments.

[ISO]current_prolog_flag(?Key, -Value)
  The predicate current_prolog_flag/2 defines an interface to installation features: options compiled in, version, home, etc. With both arguments unbound, it will generate all defined Prolog flags. With Key instantiated, it unifies Value with the value of the Prolog flag or fails if the Key is not a Prolog flag.

  Flags marked rw can be modified by the user using set_prolog_flag/2. Flag values are typed. Flags marked as `bool` can have the values `true` or `false`. The predicate create_prolog_flag/3 may be used to create flags that describe or control behaviour of libraries and applications. The library `library(settings)` provides an alternative interface for managing notably application parameters.

  Some Prolog flags are not defined in all versions, which is normally indicated in the documentation below as ``if present and true''. A boolean Prolog flag is true iff the Prolog flag is present and the Value is the atom `true`. Tests for such flags should be written as below:

              (   current_prolog_flag(windows, true)
              ->  <Do MS-Windows things>
              ;   <Do normal things>
              )

  Some Prolog flags are scoped to a source file. This implies that if they are set using a directive inside a file, the flag value encountered when loading of the file started is restored when loading of the file is completed. Currently, the following flags are scoped to the source file: generate_debug_info and optimise.

  A new thread (see section 10) copies all flags from the thread that created the new thread (its parent).16This is implemented using the copy-on-write tecnhnique. As a consequence, modifying a flag inside a thread does not affect other threads.

  access_level(atom, changeable)
    This flag defines a normal `user' view (`user`, default) or a `system' view. In system view all system code is fully accessible as if it was normal user code. In user view, certain operations are not permitted and some details are kept invisible. We leave the exact consequences undefined, but, for example, system code can be traced using system access and system predicates can be redefined.
  address_bits(integer)
    Address size of the hosting machine. Typically 32 or 64. Except for the maximum stack limit, this has few implications to the user. See also the Prolog flag arch.
  agc_margin(integer, changeable)
    If this amount of atoms possible garbage atoms exist perform atom garbage collection at the first opportunity. Initial value is 10,000. May be changed. A value of 0 (zero) disables atom garbage collection. See also PL_register_atom().17Given that SWI-Prolog has no limit on the length of atoms, 10,000 atoms may still occupy a lot of memory. Applications using extremely large atoms may wish to call garbage_collect_atoms/0 explicitly or lower the margin.
  apple(bool)
    If present and `true`, the operating system is MacOSX. Defined if the C compiler used to compile this version of SWI-Prolog defines `__APPLE__`. Note that the unix is also defined for MacOSX.
  allow_dot_in_atom(bool, changeable)
    If `true` (default `false`), dots may be embedded into atoms that are not quoted and start with a letter. The embedded dot must be followed by an identifier continuation character (i.e., letter, digit or underscore). The dot is allowed in identifiers in many languages, which can make this a useful flag for defining DSLs. Note that this conflicts with cascading functional notation. For example, `Post.meta.author` is read as `.(Post, 'meta.author'` if this flag is set to `true`.
  allow_variable_name_as_functor(bool, changeable)
    If true (default is false), `Functor(arg)` is read as if it were written `'Functor'(arg)`. Some applications use the Prolog read/1 predicate for reading an application-defined script language. In these cases, it is often difficult to explain to non-Prolog users of the application that constants and functions can only start with a lowercase letter. Variables can be turned into atoms starting with an uppercase atom by calling read_term/2 using the option `variable_names` and binding the variables to their name. Using this feature, F(x) can be turned into valid syntax for such script languages. Suggested by Robert van Engelen. SWI-Prolog specific.
  argv(list, changeable)
    List is a list of atoms representing the application command line arguments. Application command line arguments are those that have not been processed by Prolog during its initialization. Note that Prolog's argument processing stops at `--` or the first non-option argument. See also os_argv.18Prior to version 6.5.2, argv was defined as os_argv is now. The change was made for compatibility reasons and because the current definition is more practical.
  arch(atom)
    Identifier for the hardware and operating system SWI-Prolog is running on. Used to select foreign files for the right architecture. See also section 12.2.3 and file_search_path/2.
  associated_file(atom)
    Set if Prolog was started with a prolog file as argument. Used by e.g., edit/0 to edit the initial file.
  autoload(bool, changeable)
    If `true` (default) autoloading of library functions is enabled.
  back_quotes(codes,chars,string,symbol_char, changeable)
    Defines the term-representation for back-quoted material. The default is `codes`. If --traditional is given, the default is `symbol_char`, which allows using ``` in operators composed of symbols.19Older versions had a boolean flag `backquoted_strings`, which toggled between `string` and `symbol_char`. See also section 5.2.
  backtrace(bool, changeable)
    If `true` (default), print a backtrace on an uncaught exception.
  backtrace_depth(integer, changeable)
    If backtraces on errors are enabled, this flag defines the maximum number of frames that is printed (default 20).
  backtrace_goal_depth(integer, changeable)
    The frame of a backtrace is printed after making a shallow copy of the goal. This flag determines the depth to which the goal term is copied. Default is `3'.
  backtrace_show_lines(bool, changeable)
    If `true` (default), try to reconstruct the line number at which the exception happened.
  bounded(bool)
    ISO Prolog flag. If `true`, integer representation is bound by min_integer and max_integer. If `false` integers can be arbitrarily large and the min_integer and max_integer are not present. See section 4.27.2.1.
  break_level(integer)
    Current break-level. The initial top level (started with -t) has value 0. See break/0. This flag is absent from threads that are not running a top-level loop.
  c_cc(atom, changeable)
    Name of the C compiler used to compile SWI-Prolog. Normally either gcc or cc. See section 12.5.
  c_cflags(atom, changeable)
    CFLAGS used to compile SWI-Prolog. See section 12.5.
  c_ldflags(atom, changeable)
    LDFLAGS used to link SWI-Prolog. See section 12.5.
  c_libs(atom, changeable)
    Libraries needed to link executables that embed SWI-Prolog. Typically `-lswipl` if the SWI-Prolog kernel is a shared (DLL). If the SWI-Prolog kernel is in a static library, this flag also contains the dependencies.
  c_libplso(atom, changeable)
    Libraries needed to link extensions (shared object, DLL) to SWI-Prolog. Typically empty on ELF systems and `-lswipl` on COFF-based systems. See section 12.5.
  char_conversion(bool, changeable)
    Determines whether character conversion takes place while reading terms. See also char_conversion/2.
  character_escapes(bool, changeable)
    If `true` (default), read/1 interprets `\` escape sequences in quoted atoms and strings. May be changed. This flag is local to the module in which it is changed. See section 2.16.1.3.
  colon_sets_calling_context(bool, changeable)
    Using the construct <module>:<goal> sets the calling context for executing <goal>. This flag is defined by ISO/IEC 13211-2 (Prolog modules standard). See section 6.
  color_term(bool, changeable)
    This flag is managed by library `library(ansi_term)`, which is loaded at startup if the two conditions below are both true. Note that this implies that setting this flag to `false` from the system or personal initialization file (see section 2.2 disables colored output. The predicate message_property/2 can be used to control the actual color scheme depending in the message type passed to print_message/2.

    - `stream_property(current_output, tty(true))`
    - `\+ current_prolog_flag(color_term, false)`
  compile_meta_arguments(atom, changeable)
    Experimental flag that controls compilation of arguments passed to meta-calls marked `0' or ```^``' (see meta_predicate/1). Supported values are:
    false
      (default). Meta-arguments are passed verbatim.
    control
      Compile meta-arguments that contain control structures ((A,B), (A;B), (A->B;C), etc.). If not compiled at compile time, such arguments are compiled to a temporary clause before execution. Using this option enhances performance of processing complex meta-goals that are known at compile time.
    true
      Also compile references to normal user predicates. This harms performance (a little), but enhances the power of poor-mens consistency check used by make/0 and implemented by list_undefined/0.
    always
      Always create an intermediate clause, even for system predicates. This prepares for replacing the normal head of the generated predicate with a special reference (similar to database references as used by, e.g., assert/2) that provides direct access to the executable code, thus avoiding runtime lookup of predicates for meta-calling.
  compiled_at(atom)
    Describes when the system has been compiled. Only available if the C compiler used to compile SWI-Prolog provides the __DATE__ and __TIME__ macros.
  console_menu(bool)
    Set to `true` in swipl-win.exe to indicate that the console supports menus. See also section 4.35.3.
  cpu_count(integer, changeable)
    Number of physical CPUs or cores in the system. The flag is marked read-write both to allow pretending the system has more or less processors. See also thread_setconcurrency/2 and the library `library(thread)`. This flag is not available on systems where we do not know how to get the number of CPUs. This flag is not included in a saved state (see qsave_program/1).
  dde(bool)
    Set to `true` if this instance of Prolog supports DDE as described in section 4.43.
  debug(bool, changeable)
    Switch debugging mode on/off. If debug mode is activated the system traps encountered spy points (see spy/1) and trace points (see trace/1). In addition, last-call optimisation is disabled and the system is more conservative in destroying choice points to simplify debugging.

    Disabling these optimisations can cause the system to run out of memory on programs that behave correctly if debug mode is off.

  debug_on_error(bool, changeable)
    If `true`, start the tracer after an error is detected. Otherwise just continue execution. The goal that raised the error will normally fail. See also the Prolog flag report_error. Default is `true`.
  debugger_write_options(term, changeable)
    This argument is given as option-list to write_term/2 for printing goals by the debugger. Modified by the `w', `p' and `<N> d' commands of the debugger. Default is `[quoted(true), portray(true), max_depth(10), attributes(portray)]`.
  debugger_show_context(bool, changeable)
    If `true`, show the context module while printing a stack-frame in the tracer. Normally controlled using the `C' option of the tracer.
  dialect(atom)
    Fixed to `swi`. The code below is a reliable and portable way to detect SWI-Prolog.

        is_dialect(swi) :-
                catch(current_prolog_flag(dialect, swi), _, fail).

  double_quotes(codes,chars,atom,string, changeable)
    This flag determines how double quoted strings are read by Prolog and is ---like character_escapes and back_quotes--- maintained for each module. The default is `string`, which produces a string as described in section 5.2. If --traditional is given, the default is `codes`, which produces a list of character codes, integers that represent a Unicode code-point. The value `chars` produces a list of one-character atoms and the value `atom` makes double quotes the same as single quotes, creating a atom. See also section 5.
  editor(atom, changeable)
    Determines the editor used by edit/1. See section 4.4.1 for details on selecting the editor used.
  emacs_inferior_process(bool)
    If true, SWI-Prolog is running as an inferior process of (GNU/X-)Emacs. SWI-Prolog assumes this is the case if the environment variable `EMACS` is `t` and `INFERIOR` is `yes`.
  encoding(atom, changeable)
    Default encoding used for opening files in `text` mode. The initial value is deduced from the environment. See section 2.19.1 for details.
  executable(atom)
    Pathname of the running executable. Used by qsave_program/2 as default emulator.
  exit_status(integer)
    Set by halt/1 to its argument, making the exit status available to hooks registered with at_halt/1.
  file_name_case_handling(atom, changeable)
    This flag defines how Prolog handles the case of file names. The flag is used for case normalization and to determine whether two names refer to the same file.bugNote that file name case handling is typically a properly of the filesystem, while Prolog only has a global flag to determine its file handling. It has one of the following values:
    case_sensitive
      The filesystem is fully case sensitive. Prolog does not perform any case modification or case insensitive matching. This is the default on Unix systems.
    case_preserving
      The filesystem is case insensitive, but it preserves the case with which the user has created a file. This is the default on Windows systems.
    case_insensitive
      The filesystem doesn't store or match case. In this scenario Prolog maps all file names to lower case.
  file_name_variables(bool, changeable)
    If `true` (default `false`), expand `$\arg{varname}` and ``~`` in arguments of built-in predicates that accept a file name (open/3, exists_file/1, access_file/2, etc.). The predicate expand_file_name/2 can be used to expand environment variables and wildcard patterns. This Prolog flag is intended for backward compatibility with older versions of SWI-Prolog.
  file_search_cache_time(number, changeable)
    Time in seconds for which search results from absolute_file_name/3 are cached. Within this time limit, the system will first check that the old search result satisfies the conditions. Default is 10 seconds, which typically avoids most repetitive searches for (library) files during compilation. Setting this value to 0 (zero) disables the cache.
  gc(bool, changeable)
    If true (default), the garbage collector is active. If false, neither garbage collection, nor stack shifts will take place, even not on explicit request. May be changed.
  gc_thread(bool)
    If `true` (default if threading is enabled), atom and clause garbage collection are executed in a seperate thread with the alias `gc`. Otherwise the thread that detected sufficient garbage executes the garbage collector. As running these global collectors may take relatively long, using a seperate thread improves real time behaviour. The `gc` thread can be controlled using set_prolog_gc_thread/1.
  generate_debug_info(bool, changeable)
    If `true` (default) generate code that can be debugged using trace/0, spy/1, etc. Can be set to `false` using the -nodebug. This flag is scoped within a source file. Many of the libraries have `:- set_prolog_flag(generate_debug_info, false)` to hide their details from a normal trace.20In the current implementation this only causes a flag to be set on the predicate that causes children to be hidden from the debugger. The name anticipates further changes to the compiler.
  gmp_version(integer)
    If Prolog is linked with GMP, this flag gives the major version of the GMP library used. See also section 12.4.9.
  gui(bool)
    Set to `true` if XPCE is around and can be used for graphics.
  history(integer, changeable)
    If integer> 0, support Unix csh(1)-like history as described in section 2.7. Otherwise, only support reusing commands through the command line editor. The default is to set this Prolog flag to 0 if a command line editor is provided (see Prolog flag readline) and 15 otherwise.
  home(atom)
    SWI-Prolog's notion of the home directory. SWI-Prolog uses its home directory to find its startup file as `<home>/boot32.prc` (32-bit machines) or `<home>/boot64.prc` (64-bit machines) and to find its library as `<home>/library`.
  hwnd(integer)
    In swipl-win.exe, this refers to the MS-Windows window handle of the console window.
  integer_rounding_function(down,toward_zero)
    ISO Prolog flag describing rounding by `//` and `rem` arithmetic functions. Value depends on the C compiler used.
  iso(bool, changeable)
    Include some weird ISO compatibility that is incompatible with normal SWI-Prolog behaviour. Currently it has the following effect:
    - The ``/`/2` (float division) always returns a float, even if applied to integers that can be divided.
    - In the standard order of terms (see section 4.7.1), all floats are before all integers.
    - atom_length/2 yields a type error if the first argument is a number.
    - clause/[2,3] raises a permission error when accessing static predicates.
    - abolish/[1,2] raises a permission error when accessing static predicates.
    - Syntax is closer to the ISO standard:
      - Unquoted commas and bars appearing as atoms are not allowed. Instead of `f(,,a)` now write `f(',',a)`. Unquoted commas can only be used to separate arguments in functional notation and list notation, and as a conjunction operator. Unquoted bars can only appear within lists to separate head and tail, like `[Head|Tail]`, and as infix operator for alternation in grammar rules, like `a --> b | c.`
      - Within functional notation and list notation terms must have priority below 1000. That means that rules and control constructs appearing as arguments need bracketing. A term like `[a :- b, c].` must now be disambiguated to mean `[(a :- b), c].` or `[(a :- b, c)].`
      - Operators appearing as operands must be bracketed. Instead of `X == -, true.` write `X == (-), true.` Currently, this is not entirely enforced.
      - Backslash-escaped newlines are interpreted according to the ISO standard. See section 2.16.1.3.
  large_files(bool)
    If present and `true`, SWI-Prolog has been compiled with large file support (LFS) and is capable of accessing files larger than 2GB on 32-bit hardware. Large file support is default on installations built using configure that support it and may be switched off using the configure option `--disable-largefile`.
  last_call_optimisation(bool, changeable)
    Determines whether or not last-call optimisation is enabled. Normally the value of this flag is the negation of the debug flag. As programs may run out of stack if last-call optimisation is omitted, it is sometimes necessary to enable it during debugging.
  max_arity(unbounded)
    ISO Prolog flag describing there is no maximum arity to compound terms.
  max_integer(integer)
    Maximum integer value if integers are bounded. See also the flag bounded and section 4.27.2.1.
  max_tagged_integer(integer)
    Maximum integer value represented as a `tagged' value. Tagged integers require one word storage. Larger integers are represented as `indirect data' and require significantly more space.
  message_context(list(atom), changeable)
    Context information to add to messages of the levels `error` and `warning`. The list may contain the elements `thread` to add the thread that generates the message to the message, `time` or `time(Format)` to add a time stamp. The default time format is `%T.%3f`. The default is `[thread]`. See also format_time/3 and print_message/2.
  min_integer(integer)
    Minimum integer value if integers are bounded. See also the flag bounded and section 4.27.2.1.
  min_tagged_integer(integer)
    Start of the tagged-integer value range.
  mitigate_spectre(bool, changeable)
    When `true` (default `false`), enforce mitigation against the Spectre timing-based security vulnerability. Spectre based attacks can extract information from memory owned by the process that should remain invisible, such as passwords or the private key of a web server. The attacks work by causing speculative access to sensitive data, and leaking the data via side-channels such as differences in the duration of successive instructions. An example of a potentially vulnerable application is SWISH. SWISH allows users to run Prolog code while the swish server must protect the privacy of other users as well as its HTTPS private keys, cookies and passwords.

    Currently, enabling this flag reduces the resolution of get_time/1 and statistics/2 CPU time to 20&mus.

    WARNING: Although a coarser timer makes a successful attack of this type harder, it does not reliably prevent such attacks in general. Full mitigation may require compiler support to disable speculative access to sensitive data.

  occurs_check(atom, changeable)
    This flag controls unification that creates an infinite tree (also called cyclic term) and can have three values. Using `false` (default), unification succeeds, creating an infinite tree. Using `true`, unification behaves as unify_with_occurs_check/2, failing silently. Using `error`, an attempt to create a cyclic term results in an `occurs_check` exception. The latter is intended for debugging unintentional creations of cyclic terms. Note that this flag is a global flag modifying fundamental behaviour of Prolog. Changing the flag from its default may cause libraries to stop functioning properly.
  open_shared_object(bool)
    If true, open_shared_object/2 and friends are implemented, providing access to shared libraries (`.so` files) or dynamic link libraries (`.DLL` files).
  optimise(bool, changeable)
    If `true`, compile in optimised mode. The initial value is `true` if Prolog was started with the -O command line option. The optimise flag is scoped to a source file.

    Currently optimised compilation implies compilation of arithmetic, and deletion of redundant true/0 that may result from expand_goal/2.

    Later versions might imply various other optimisations such as integrating small predicates into their callers, eliminating constant expressions and other predictable constructs. Source code optimisation is never applied to predicates that are declared dynamic (see dynamic/1).

  os_argv(list, changeable)
    List is a list of atoms representing the command line arguments used to invoke SWI-Prolog. Please note that all arguments are included in the list returned. See argv to get the application options.
  pid(int)
    Process identifier of the running Prolog process. Existence of this flag is implementation-defined.
  pipe(bool, changeable)
    If true, `open(pipe(command), mode, Stream)`, etc. are supported. Can be changed to disable the use of pipes in applications testing this feature. Not recommended.
  posix_shell(atom, changeable)
    Path to a POSIX compatible shell. This default is typically `/bin/sh`. This flag is used by shell/1 and qsave_program/2.
  print_write_options(term, changeable)
    Specifies the options for write_term/2 used by print/1 and print/2.
  tmp_dir(atom, changeable)
    Path to the temporary directory. initialised from the environment variable `TMP` or `TEMP` in windows. If this variable is not defined a default is used. This default is typically `/tmp` or `c:/temp` in windows.
  prompt_alternatives_on(atom, changeable)
    Determines prompting for alternatives in the Prolog top level. Default is `determinism`, which implies the system prompts for alternatives if the goal succeeded while leaving choice points. Many classical Prolog systems behave as `groundness`: they prompt for alternatives if and only if the query contains variables.
  protect_static_code(bool, changeable)
    If `true` (default `false`), clause/2 does not operate on static code, providing some basic protection from hackers that wish to list the static code of your Prolog program. Once the flag is `true`, it cannot be changed back to `false`. Protection is default in ISO mode (see Prolog flag iso). Note that many parts of the development environment require clause/2 to work on static code, and enabling this flag should thus only be used for production code.
  qcompile(atom, changeable)
    This option provides the default for the `qcompile(+Atom)` option of load_files/2.
  readline(atom, changeable)
    Specifies which form of command line editing is provided. Possible values are below. The flag may be set from the user's init file (see section 2.3) to one of `false`, `readline` or `editline`. This causes the toplevel not to load a command line editor (`false`) or load the specified one. If loading fails the flag is set to `false`.
    false
      No command line editing is available.
    readline
      The library `library(readline)` is loaded, providing line editing based on the GNU readline library.
    editline
      The library `library(editline)` is loaded, providing line editing based on the BSD libedit. This is the default if `library(editline)` is available and can be loaded.
    swipl_win
      SWI-Prolog uses its own console (swipl-win.exe on Windows, the Qt based swipl-win on MacOS) which provides line editing.
  resource_database(atom)
    Set to the absolute filename of the attached state. Typically this is the file `boot32.prc`, the file specified with -x or the running executable. See also resource/3.
  report_error(bool, changeable)
    If `true`, print error messages; otherwise suppress them. May be changed. See also the debug_on_error Prolog flag. Default is `true`, except for the runtime version.
  runtime(bool)
    If present and `true`, SWI-Prolog is compiled with -DO_RUNTIME, disabling various useful development features (currently the tracer and profiler).
  sandboxed_load(bool, changeable)
    If `true` (default `false`), load_files/2 calls hooks to allow library(sandbox) to verify the safety of directives.
  saved_program(bool)
    If present and `true`, Prolog has been started from a state saved with qsave_program/[1,2].
  shared_object_extension(atom)
    Extension used by the operating system for shared objects. `.so` for most Unix systems and `.dll` for Windows. Used for locating files using the `file_type` `executable`. See also absolute_file_name/3.
  shared_object_search_path(atom)
    Name of the environment variable used by the system to search for shared objects.
  signals(bool)
    Determine whether Prolog is handling signals (software interrupts). This flag is `false` if the hosting OS does not support signal handling or the command line option -nosignals is active. See section 12.4.22.1 for details.
  stack_limit(int, changeable)
    Limits the combined sizes of the Prolog stacks for the current thread. See alse --stack and section 2.20.1.
  stream_type_check(atom, changeable)
    Defines whether and how strictly the system validates that byte I/O should not be applied to text streams and text I/O should not be applied to binary streams. Values are `false` (no checking), `true` (full checking) and `loose`. Using checking mode `loose` (default), the system accepts byte I/O from text stream that use ISO Latin-1 encoding and accepts writing text to binary streams.
  system_thread_id(int)
    Available in multithreaded version (see section 10) where the operating system provides system-wide integer thread identifiers. The integer is the thread identifier used by the operating system for the calling thread. See also thread_self/1.
  table_space(integer, changeable)
    Space reserved for storing answer tables for tabled predicates (see table/1).bugCurrently only counts the space occupied by the nodes in the answer tries. When exceeded a `resource_error(table_space)` exception is raised.
  threads(bool, changeable)
    True when threads are supported. If the system is compiled without thread support the value is `false` and read-only. Otherwise the value is `true` unless the system was started with the --nothreads. Threading may be disabled only if no threads are running. See also the gc_thread flag.
  timezone(integer)
    Offset in seconds west of GMT of the current time zone. Set at initialization time from the `timezone` variable associated with the POSIX tzset() function. See also format_time/3.
  toplevel_goal(term, changeable)
    Defines the goal that is executed after running the initialization goals and entry point (see -g, initialization/2 and section 2.10.2.1. The initial value is `default`, starting a normal interactive session. This value may be changed using the command line option -t. The explicit value `prolog` is equavalent to `default`. If `initialization(Goal,main)` is used and the toplevel is `default`, the toplevel is set to `halt` (see halt/0).
  toplevel_mode(atom, changeable)
    If `backtracking` (default), the toplevel backtracks after completing a query. If `recursive`, the toplevel is implemented as a recursive loop. This implies that global variables set using b_setval/2 are maintained between queries. In recursive mode, answers to toplevel variables (see section 2.8) are kept in backtrackable global variables and thus not copied. In backtracking mode answers to toplevel variables are kept in the recorded database (see section 4.14.2).

    The recursive mode has been added for interactive usage of CHR (see section 9),21Suggested by Falco Nogatz which maintains the global constraint store in backtrackable global variables.

  toplevel_print_anon(bool, changeable)
    If `true`, top-level variables starting with an underscore (`_`) are printed normally. If `false` they are hidden. This may be used to hide bindings in complex queries from the top level.
  toplevel_print_factorized(bool, changeable)
    If `true` (default `false`) show the internal sharing of subterms in the answer substitution. The example below reveals internal sharing of leaf nodes in red-black trees as implemented by the `library(rbtrees)` predicate rb_new/1 :

        ?- set_prolog_flag(toplevel_print_factorized, true).
        ?- rb_new(X).
        X = t(_S1, _S1), % where
            _S1 = black('', _G387, _G388, '').

    If this flag is `false`, the `% where` notation is still used to indicate cycles as illustrated below. This example also shows that the implementation reveals the internal cycle length, and not the minimal cycle length. Cycles of different length are indistinguishable in Prolog (as illustrated by `S == R`).

        ?- S = s(S), R = s(s(R)), S == R.
        S = s(S),
        R = s(s(R)).

  answer_write_options(term, changeable)
    This argument is given as option-list to write_term/2 for printing results of queries. Default is `[quoted(true), portray(true), max_depth(10), attributes(portray)]`.
  toplevel_prompt(atom, changeable)
    Define the prompt that is used by the interactive top level. The following `~` (tilde) sequences are replaced:

    ``~``m | Type in module if not `user` (see module/1)
    ``~``l | Break level if not 0 (see break/0)
    ``~``d | Debugging state if not normal execution (see debug/0, trace/0)
    ``~``! | History event if history is enabled (see flag history)

  toplevel_var_size(int, changeable)
    Maximum size counted in literals of a term returned as a binding for a variable in a top-level query that is saved for re-use using the ``$`` variable reference. See section 2.8.
  trace_gc(bool, changeable)
    If `true` (default `false`), garbage collections and stack-shifts will be reported on the terminal. May be changed. Values are reported in bytes as G+T, where G is the global stack value and T the trail stack value. `Gained' describes the number of bytes reclaimed. `used' the number of bytes on the stack after GC and `free' the number of bytes allocated, but not in use. Below is an example output.

        % GC: gained 236,416+163,424 in 0.00 sec;
              used 13,448+5,808; free 72,568+47,440

  traditional(bool)
    Available in SWI-Prolog version 7. If `true`, `traditional' mode has been selected using --traditional. Notice that some SWI7 features, like the functional notation on dicts, do not work in this mode. See also section 5.
  tty_control(bool, changeable)
    Determines whether the terminal is switched to raw mode for get_single_char/1, which also reads the user actions for the trace. May be set. If this flag is `false` at startup, command line editing is disabled. See also the --no-tty command line option.
  unix(bool)
    If present and `true`, the operating system is some version of Unix. Defined if the C compiler used to compile this version of SWI-Prolog either defines `__unix__` or `unix`. On other systems this flag is not available. See also apple and windows.
  unknown(fail,warning,error, changeable)
    Determines the behaviour if an undefined procedure is encountered. If `fail`, the predicate fails silently. If `warn`, a warning is printed, and execution continues as if the predicate was not defined, and if `error` (default), an `existence_error` exception is raised. This flag is local to each module and inherited from the module's import-module. Using default setup, this implies that normal modules inherit the flag from `user`, which in turn inherit the value `error` from `system`. The user may change the flag for module `user` to change the default for all application modules or for a specific module. It is strongly advised to keep the `error` default and use dynamic/1 and/or multifile/1 to specify possible non-existence of a predicate.
  unload_foreign_libraries(bool, changeable)
    If `true` (default `false`), unload all loaded foreign libraries. Default is `false` because modern OSes reclaim the resources anyway and unloading the foreign code may cause registered hooks to point to no longer existing data or code.
  user_flags(Atom, changeable)
    Define the behaviour of set_prolog_flag/2 if the flag is not known. Values are `silent`, `warning` and `error`. The first two create the flag on-the-fly, where `warning` prints a message. The value `error` is consistent with ISO: it raises an existence error and does not create the flag. See also create_prolog_flag/3. The default is `silent`, but future versions may change that. Developers are encouraged to use another value and ensure proper use of create_prolog_flag/3 to create flags for their library.
  var_prefix(bool, changeable)
    If `true` (default `false`), variables must start with an underscore (`_`). May be changed. This flag is local to the module in which it is changed. See section 2.16.1.7.
  verbose(atom, changeable)
    This flag is used by print_message/2. If its value is `silent`, messages of type `informational` and `banner` are suppressed. The -q switches the value from the initial `normal` to `silent`.
  verbose_autoload(bool, changeable)
    If `true` the normal consult message will be printed if a library is autoloaded. By default this message is suppressed. Intended to be used for debugging purposes.
  verbose_load(atom, changeable)
    Determines messages printed for loading (compiling) Prolog files. Current values are `full` (print a message at the start and end of each file loaded), `normal` (print a message at the end of each file loaded), `brief` (print a message at end of loading the toplevel file), and `silent` (no messages are printed, default). The value of this flag is normally controlled by the option `silent(Bool)` provided by load_files/2.
  verbose_file_search(bool, changeable)
    If `true` (default `false`), print messages indicating the progress of absolute_file_name/[2,3] in locating files. Intended for debugging complicated file-search paths. See also file_search_path/2.
  version(integer)
    The version identifier is an integer with value:

    > 10000 × Major + 100 × Minor + Patch

  version_data(swi(Major, Minor, Patch, Extra))
    Part of the dialect compatibility layer; see also the Prolog flag dialect and section C. Extra provides platform-specific version information as a list. Extra is used for tagged versions such as ``7.4.0-rc1'', in which case Extra contains a term `tag(rc1)`.
  version_git(atom)
    Available if created from a git repository. See git-describe for details.
  windows(bool)
    If present and `true`, the operating system is MS-Windows.
  wine_version(atom)
    If present, SWI-Prolog is the MS-Windows version running under the Wine emulator.
  warn_override_implicit_import(bool, changeable)
    If `true` (default), a warning is printed if an implicitly imported predicate is clobbered by a local definition. See use_module/1 for details.
  win_file_access_check(atom, changeable)
    Controls the behaviour or access_file/2 under Windows. There is no reliable way to check access to files and directories on Windows. This flag allows for switching between three alternative approximations.
    access
      Use Windows _waccess() function. This ignores ACLs (Access Control List) and thus may indicate that access is allowed while it is not.
    getfilesecurity
      Use the Windows GetFileSecurity() function. This does not work on all file systems, but is probably the best choice on file systems that do support it, notably local NTFS volumes.
    openclose
      Try to open the file and close it. This works reliable for files, but not for directories. Currently directories are checked using _waccess(). This is the default.
  windows(bool)
    If present and `true`, the operating system is an implementation of Microsoft Windows. This flag is only available on MS-Windows based versions. See also unix.
  write_attributes(atom, changeable)
    Defines how write/1 and friends write attributed variables. The option values are described with the `attributes` option of write_term/3. Default is `ignore`.
  write_help_with_overstrike(bool)
    Internal flag used by help/1 when writing to a terminal. If present and `true` it prints bold and underlined text using overstrike.
  xpce(bool)
    Available and set to `true` if the XPCE graphics system is loaded.
  xpce_version(atom)
    Available and set to the version of the loaded XPCE system.
  xref(bool, changeable)
    If `true`, source code is being read for analysis purposes such as cross-referencing. Otherwise (default) it is being read to be compiled. This flag is used at several places by term_expansion/2 and goal_expansion/2 hooks, notably if these hooks use side effects. See also the libraries `library(prolog_source)` and `library(prolog_xref)`.
[ISO]set_prolog_flag(:Key, +Value)
  Define a new Prolog flag or change its value. Key is an atom. If the flag is a system-defined flag that is not marked changeable above, an attempt to modify the flag yields a `permission_error`. If the provided Value does not match the type of the flag, a `type_error` is raised.

  Some flags (e.g., unknown) are maintained on a per-module basis. The addressed module is determined by the Key argument.

  In addition to ISO, SWI-Prolog allows for user-defined Prolog flags. The type of the flag is determined from the initial value and cannot be changed afterwards. Defined types are `boolean` (if the initial value is one of `false`, `true`, `on` or `off`), `atom` if the initial value is any other atom, `integer` if the value is an integer that can be expressed as a 64-bit signed value. Any other initial value results in an untyped flag that can represent any valid Prolog term.

  The behaviour when Key denotes a non-existent key depends on the Prolog flag user_flags. The default is to define them silently. New code is encouraged to use create_prolog_flag/3 for portability.

[YAP]create_prolog_flag(+Key, +Value, +Options)
  Create a new Prolog flag. The ISO standard does not foresee creation of new flags, but many libraries introduce new flags. Options is a list of the options below. See also user_flags.
  access(+Access)
    Define access rights for the flag. Values are `read_write` and `read_only`. The default is `read_write`.
  type(+Atom)
    Define a type restriction. Possible values are `boolean`, `atom`, `integer`, `float` and `term`. The default is determined from the initial value. Note that `term` restricts the term to be ground.
  keep(+Boolean)
    If `true`, do not modify the flag if it already exists. Otherwise (default), this predicate behaves as set_prolog_flag/2 if the flag already exists.