Availability:built-in
![Show source Source](/linkedpolitics/swish/pldoc/res/source.png)
A portable solution for threading state through a DCG can be implemented by wrapping the state in a list and use the DCG semicontext facility. Subsequently, the following predicates may be used to access and modify the state:80This solution was proposed by Markus Triska.
state(S), [S] --> [S]. state(S0, S), [S] --> [S0].