User:Kevin Reid/User far proxy

From Erights

< User:Kevin Reid
Revision as of 14:03, 6 May 2010 by Kevin Reid (Talk)
(diff) ←Older revision | Current revision (diff) | Newer revision→ (diff)
Jump to: navigation, search

The basic idea here is that there ought to be a way for a user to interactively provide the behavior of a far ref: for general interactive use where a callback is wanted, for debugging eventual protocols, and for demonstrating how E works.

This ties directly into the interactive object manipulation ideas that are part of [[./E-AUI]] but I haven't implemented it in that framework yet.

This is a draft REPL-based implementation which I wrote July 26, 2008. I haven't checked whether it works. —Kevin Reid 09:03, 6 May 2010 (CDT)

The UI design is that notifications are printed to stdout with an index n, and the arguments and return-value resolver are obtained by verb[n], args[n], and reply[n].

var lastID := 0
def verbs := [].asMap().diverge()
def args  := [].asMap().diverge()
def reply := [].asMap().diverge()
def make(label :String) {
  return makeProxy(def handler {
    to handleSendOnly(verb, args) {
      def thisID := lastID += 1
      stdout.println(`$label received $verb$args [$thisID]`)
      verbs[thisID] := verb
      args[thisID] := args
    }
    to handleSend(verb, args) {
      handler.handleSendOnly(verb, args)
      stdout.println(`Expecting a reply`)
      def thisID := lastID # XXX kludge
      reply[thisID] := def response
      response
    }
  })
}
Personal tools
more tools