declare fun {SumPortMaker} Strm % declaring the input stream fun {Loop Nums N} case Nums of X|Xs then {Loop Xs N+X} end end in thread _={Loop Strm 0} end {NewPort Strm} end % clients can do... PSum = {SumPortMaker} {Send PSum 3} {Send PSum 7} fun {SumAgentMaker} Strm % declaring the input stream fun {Loop MsgStrm N} case MsgStrm of add(X)|Msgs then {Loop Msgs N+X} [] get(Z)|Msgs then Z=N {Loop Msgs N} end end in thread _={Loop Strm 0} end {NewPort Strm} end % clients can do... SumPObj = {SumAgentMaker} {Send SumPObj add(3)} {Send SumPObj add(7)} local Z in {Send SumPObj get(Z)} {Browse Z} end