[e-lang] Q: asynchronous tail recursion?

Mark S. Miller markm at cs.jhu.edu
Tue Jan 2 10:30:02 CST 2007


Kevin Reid wrote:
> On Dec 29, 2006, at 23:20, Mark S. Miller wrote:
>> [...] distributed weak references make me nervous, and I'd like to avoid  
>> them.
> 
> I agree, but can you think of any technical reason they could not be  
> implemented as I described?

Earlier, Kevin Reid wrote:
> My answer is that it depends on the type of incoming reference.  
> Remote weak references would have their own incoming and outgoing  
> tables. The incoming table would be weak-valued.
> 
> When you make a weak reference, the maker would note that the target  
> is a Far-proxy, and requests the ref's comm system to make a weak  
> outgoing reference.


IIUC, what you're proposing is essentially a normal far reference to a 
weak-reference object, which itself would be local to the object it 
designates. Once we support genuine Data-E PassByConstruction, this should be 
an adequate hook for causing the remote creation of such a weak reference. 
AFAICT, this should work fine.


>> In any case, if local eventual loops are tail-recursive, 
>> [...] I don't see what the remaining distributed tail- 
>> recursion issue is. Can someone provide an example?
> 
> Here's a silly (useless) example. As control passes around the ring,  
> the potential for breaking it does too, so the return value path is  
> moved with it, and this would accumulate forwarders.
> 
> I can't think of a decent reason to want to use a token ring in E,  
> though.
> 
> 
> # nodes to be distributed
> def makeTokenRingNode(next) implements PassByCopy {
>    return def node {
>      to token() {
>        if (entropy.nextInt(1000) == 0) {
>          throw("failure")
>        }
>        return next <- token()
>      }
>    }
> }
> 
> # make a ring
> def [var link, tail] := Ref.promise()
> for recipient in vatTargets {
> 
>    # assume 'recipient' is an object which will just invoke its
>    # argument in that vat
> 
>    def thisNext := link
> 
>    link := recipient <- run(def _() implements PassByCopy {
>      return makeTokenRingNode(thisNext)
>    })
> }
> tail.resolve(link)
> 
> def status := link <- token() # start the circulation
> 
> Ref.whenBroken(status, def _(problem) {
>    println(`Ring broken: $problem`)
> })
> 


If each of the participating vats are doing local tail-recursive promise 
shortening, as you've implemented, then this should combine with the 
distributed promise-chain shortening already implemented by CapTP (as driven 
by __whenMoreResolved messages) to prevent any accumulation. Perhaps I 
misunderstand the example?


-- 
Text by me above is hereby placed in the public domain

     Cheers,
     --MarkM


More information about the e-lang mailing list