Got a question about the translation of conditions in alts to
libthread, specifically the example in Russ's talk at
<http://swtch.com/~rsc/talks/threads07/#(33)>.

The syntax,
    alt {
    x = <-c1:
        print("received %d from c1\n", x);
    cond && c2 <-= y:
        print("sent %d to c2\n", y);
    }
implies that the condition is re-evaluated.  I.e., if c1 isn't ready
and c2 is but cond is false, then the alt blocks until either c1
becomes ready or the condition turn true.  The libthread translation,
    alts[1] = (Alt){c2, &y, cond ? CHANSND : CHANNOP};
    alts[2] = (Alt){nil, nil, CHANEND};
    switch(alt(alts)){
    …
on the other hand, makes it pretty clear that the condition is
evaluated only once.  Is that a limitation of the implementation of
libthread, or are those the intended semantics?

--Joel

Reply via email to