[e-lang] EProxyResolver and sameness-breaking

Mark Miller erights at gmail.com
Fri Mar 23 18:47:57 CDT 2007


On 3/23/07, Mark Miller <erights at gmail.com> wrote:
> The next message will contain the untested
> makeMultiChannel.emaker, which requires the new makeProxy mechanism.

Here it is. Shortly, we should find out how foolish I've been ;).

------- makeMultiChannel.emaker ------------
#!/usr/bin/env rune

# Copyright 2007 Hewlett Packard, under the terms of the MIT X license
# found at http://www.opensource.org/licenses/mit-license.html ................

pragma.syntax("0.9")

# NEVER is a promise that never resolves.
def [NEVER,_] := Ref.promise()

def makeStitchPair := <import:org.erights.e.tools.collect.makeStitchPair>

def flip(item) :any {
    def flipped(func) :void {
        func(item)
    }
    return flipped
}


def makeMultiChannel() {
    def [left,right] := makeStitchPair()
    def acceptorHandler {
        to handleSendOnly(verb :String, args :List) :void {
            def func(item) :void {
                E.sendOnly(item, verb, args)
            }
            left.apply(func, func)
        }
        to handleSend(verb :String, args :List) :any {
            def [result, resultD] := makeMultiChannel()
            def func(item) :void {
                resultD.forward(E.send(item, verb, args))
            }
            left.apply(func, func)
            return result
        }
    }
    # To E, an acceptor is a kind of Remote Promise that delivers messages
    # but never resolves.
    def acceptor := makeProxy(acceptorHandler,NEVER,false)
    def distributor {
        to forward(item) {
            right.apply(flip(item), item)
        }
    }
    return [acceptor, distributor]
}


More information about the e-lang mailing list