% Since Prova 1.90
% This example demonstrates
% - the use of explicit lists in the rest of other lists (see the first sendMsg).
% - the rcvMsg/rcvMult inline reactions now allow using list rests after the
%       required five parameters. This allows matching against any context
%       (additional parameters unique to a particular conversation) sent with the message.   

w(X) :-
	Y = dummy,
	println(["w=", X, "."]),
	sendMsg(XID, self, 0, msga, X|[Y,[Y]]),
	rcvMsg(XID, _, _, msgb, W|CC),
	println(imsgb(W,CC)).

rcvMsg(XID, P, Ag, msga, X |Ctx) :-
	sendMsg(XID, P, Ag, msgb, msga(X) |Ctx).

rcvMsg(XID, P, Ag, msgb, W |Ctx) :-
	println([msgb(W |Ctx)]]).

:- eval(w(x())).

% Prints:
% w=["x"].
% imsgb["msga",["x"]]["dummy",["dummy"]]
% ["msgb",["msga",["x"]],"dummy",["dummy"]]