2.12 Environment Control (Prolog flags)
All Application Manual Name SummaryHelp

  • Documentation
    • Reference manual
      • Overview
        • Environment Control (Prolog flags)
          • current_prolog_flag/2
          • set_prolog_flag/2
          • create_prolog_flag/3
    • Packages
Availability:built-in
[ISO]set_prolog_flag(:Key, +Value)
Set the value of a Prolog flag. 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 meta argument.

In addition to ISO, SWI-Prolog allows for user-defined Prolog flags. New Prolog flags should be created using create_prolog_flag/3. For historical reasons set_prolog_flag/2 silently creates a Prolog flag if the Prolog flag user_flags is true (default), i.e., set_prolog_flag/2 behaves as if defined below.

set_prolog_flag(Key, Value) :-
    current_prolog_flag(Key, _),
    !,
    <set the flag>.
set_prolog_flag(Key, Value) :-
    current_prolog_flag(user_flags, true),
    !,
    create_prolog_flag(Key, Value, []).
set_prolog_flag(Key, _) :-
    existence_error(prolog_flag, Key).