Updatable Cell Agent

Port, stream and concurrency make it possible to create stateful abstractions

{NewCell Init ?P}: input initial value Init, output a port P identifying the cell
proc {Access P X} {Send P get(X)} end
proc {Assign P X} {Send P put(X)} end
proc {NewCell Init P}
   thread {CellAgent Init {NewPort $ P}} end
end
proc {CellAgent V L}
   case L
   of get(X)|T then X=V {CellAgent V L}
   [] put(X)|T then     {CellAgent X L}
   end
end