Predicate channel/2 can be used to declare channels dynamically.
The following names a channel C which connects a group of
participants denoted by Agent1, Agent2, ..., Agentn:
Agenti can be a defined static channel name, a role name, some self, or even another defined dynamic channel name. A channel (static or dynamic, excluding that denoted by a role name) can be later redefined. The same channel predicate, if the second argument is a variable, can be used to get the list of agents connected by a given channel.
An offer predicate can send messages through a variable channel
like the following.
However, the variable C must have been
bound to an agent (some self), an agent group, a role name,
or a declared channel name.
There are two ways to receive messages sent via a dynamical channel. One is to define active rules at the gate denoted self. Another way is to define an active rule in which the gate name is a variable. When a message arrives not unifying with any active rules with constant gate names, the variable gates rules will be tried.