[e-lang] Q: asynchronous tail recursion?
Kevin Reid
kpreid at mac.com
Mon Jan 1 21:51:51 CST 2007
On Dec 29, 2006, at 23:20, Mark S. Miller wrote:
> Kevin Reid wrote:
>> I'm not a CapTP expert, but I can't think of any any reason why this
>> couldn't be done with little added complexity. Could someone who does
>> know speak up?
>
> Well, I suppose that would be me. I tend to agree with Constantine --
> 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?
> In any case, if local eventual loops are tail-recursive, whether
> using Kevin's technique
I have now implemented this technique in E-on-CL.
(E-on-CL now depends on the 'trivial-garbage' library for multi-
platform weak hash tables, which will need to be installed like its
other dependencies.)
> or Constantine's, 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`)
})
--
Kevin Reid <http://homepage.mac.com/kpreid/>
More information about the e-lang
mailing list