11.3.163 prolog_flag/[2,3]

Synopsis

prolog_flag(?FlagName, ?Value)

FlagName is a flag, which currently is set to Value.

prolog_flag(+FlagName, -OldValue, +NewValue)

Unifies the current value of FlagName with OldValue and then sets the value of the flag to NewValue. The available Prolog flags are listed in ref-lps-flg.

Arguments

FlagName
atom, must be nonvar and a legal flag in prolog_flag/3
Value
term
OldValue
term
NewValue
term, must be nonvar and belong to proper type/domain

Description

To inspect the value of a flag without changing it, use prolog_flag/2 or the following idiom, where FlagName is bound to one of the valid flags above.

      | ?- prolog_flag(FlagName, Value, Value).

Use prolog_flag/2 to query and set_prolog_flag/2 or prolog_flag/3 to set values.

prolog_flag/3 can be used to save flag values so that one can return a flag to its previous state. For example:

     ...
     prolog_flag(debugging,Old,on), % Save in Old and set
     ...
     prolog_flag(debugging,_,Old),  % Restore from Old
     ...

Backtracking

prolog_flag/2 enumerates all valid flagnames of a given current value, or all pairs of flags and their current values.

Exceptions

instantiation_error
In prolog_flag/3, FlagName unbound, or NewValue unbound and not identical to OldValue.
type_error
FlagName is not an atom.
domain_error
In prolog_flag/3, FlagName bound to an atom that does not represent a supported flag, or NewValue bound to a term that does not represent a valid value for FlagName.
permission_error
In prolog_flag/3, NewValue not identical to OldValue for a read-only flag.

Examples

     | ?- prolog_flag(X,Y).
     X = bounded,
     Y = false ? ;
     
     yes
     
     | ?- prolog_flag(X,Y,Y).
     ! Instantiation error in argument 1 of prolog_flag/3
     ! goal:  prolog_flag(_94,_95,_95)
     
     | ?- prolog_flag(source_info,X,X).
     
     X = on ?
     
     yes

See Also

current_prolog_flag/2, set_prolog_flag/2, ref-lps-flg.


Send feedback on this subject.