{- - Event implementation in Pict -} import "types" def event (p:Agent s:Agent c:String) : Event = (new publisher:^Agent run publisher!p new space:^Agent run space!s new content:^String run content!c (rec [ publish = \[self:Event c:Sig] = (new c1:^[] new c2:^[] new c3:^[] (space?s = (space!s | (val (rec ss) = s (ss.receiveEvent![self (rchan c1)] | ss.sendEvent![self (rchan c2)] | publisher?p = (publisher!p | if (not (eqAgent s p)) then (val (rec pp) = p pp.sendEvent![self (rchan c3)]) else c3![] )))) | c1?[] = c2?[] = c3?[] = (c![] | content?x = (content!x | ((prNL (+$ x " published!")); ()))))) print = \[c:Sig] = publisher?p = space?s = content?x = (publisher!p | space!s | content!x | (val (rec pp) = p val (rec ss) = s prNL![(+$ > (pp.toString) " wrote in " (ss.toString) "'s space: " x) c] )) getPublisher = \[res:!String] = publisher?p = ( publisher!p | (val (rec pp) = p res!(pp.toString)) ) getSpace = \[res:!String] = space?s = ( space!s | (val (rec ss) = s res!(ss.toString)) ) getContent = \[res:!String] = content?x = (content!x | res!x) ]))