> 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.
Doesn't imply that to me.
> 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?
When I wrote the syntax at the top, I meant the
semantics to be what the libthread translation says.
If you look at how I used it the one time it was in the
slides, the condition couldn't change while the alt was
blocked -- it involved only local variables. In fact if
you have arranged things so that there are no shared
mutable variables then the condition can't possibly
change during the alt. So this is reasonable.
Russ