[e-lang] makeStitchPair (was EProxyResolver and ...)

Kevin Reid kpreid at mac.com
Sat Mar 24 15:14:30 CDT 2007

On Mar 23, 2007, at 19:45, Mark Miller wrote:
> On 3/23/07, Mark Miller <erights at gmail.com> wrote:
>>> I have this implemented in E-on-CL, but only in a form too ugly to
>>> publish; I will improve and commit it soon.
>>> I am also working on implementing this proxy system in E-on-Java.
> Perhaps foolishly, I am posting a use of this abstraction ahead of its
> availability, so I haven't yet tested it. This is an implementation of
> most of Joule's MultiChannel abstraction for use in E. (This does not
> yet support Joule's "choose" operation".) I've divided it into two
> part. Below is the contents of makeStitchPair.emaker, together with a
> brief updoc test. The next message will contain the untested
> makeMultiChannel.emaker, which requires the new makeProxy mechanism.
> ------- makeStitchPair.emaker ------------

I'm impressed. Even after reading the code, the examples, and  
experimenting with it, I still don't know how it does what it does. :)

The behavior I have determined experimentally: Upon each call to  
stitch.apply(f, x), it records x, and eventually applies f to every x  
given to the other stitch so far.

I also understand that it's using linked list techniques to allow the  
item/func storage to be reclaimed when one half of the pair is  


Shouldn't the "store" method be a private facet? You don't give an  
example of its use externally, and it looks like it could be used to  
make the pair misbehave.

Given the patterns of usage so far, does that makeStitchPair do  
anything that the following (which is built out of pieces I  
understand) doesn't?

(makeCollector is modified from org.cubik.den.util.buildIncrementalList)

def makeCollector() {
     def [head, var tailResolver] := Ref.promise()
     def append(x) {
         def [newTail, newTailResolver] := Ref.promise()
         tailResolver.resolve([x, newTail])
         tailResolver := newTailResolver
     def reader {
         to iterate(f) {
             var here := head
             while (Ref.isResolved(here)) {
                 f(null, here[0])
                 here := here[1]
     return [reader, append]

def makeStitchPair() {
    def [fs, fpush] := makeCollector()
    def [xs, xpush] := makeCollector()
     def left(f) {
         for x in xs { f <- (x) }
     def right(x) {
         for f in fs { f <- (x) }
     return [left, right]

Kevin Reid                            <http://homepage.mac.com/kpreid/>

More information about the e-lang mailing list