Re: Experimental "peer to peer" modular programming concept
- Posted by ryanj May 08, 2015
- 1824 views
Spock said...
Is the resulting published message the same format as standard message passing in the GUI? (I guess I could've checked the code myself.. just lazy.. ). If it were the same would it be possible/desirable to merge the functionality? ie, inject the messages into the usual message stream. Just a thought.
Spock
It is similar to GUI event handling, but more generic. Any part of the program can publish or subscribe to a topic. It is up to the programmer to define topics, message names, and message data formats, which should be listed in comments somewhere. I suppose this encourages good documentation and organization.
public procedure publish(sequence topicname, sequence subscribername, sequence msgname, object msgdata) --send data to other subscribers to a topic by calling each subscriber's message handler proc atom idx = find(topicname, gNames) if idx > 0 then for s = 1 to length(gSubscriberNames[idx]) do if not equal(gSubscriberNames[idx][s], subscribername) then if gSubscriberRids[idx][s] > 0 then call_proc(gSubscriberRids[idx][s], {topicname, subscribername, msgname, msgdata}) end if end if end for end if if debugRid > 0 then call_proc(debugRid, {topicname, subscribername, msgname, msgdata}) end if end procedure