What if we did without the timer variable?
alt {
x = <-c => print("%d\n", x);
timeout 1 => print("1 second passed\n");
}
You could model the timer variable easily enough:
t := time()+10;
for(;;){
alt {
x = <-c => print("%d\n", x);
timeout t-time() => print("10 seconds passed\n"); break;
}
}
which do you think would be more common? I think the former,
hence the dropping of explicit timer variables.
Once you've figured out what a good interface is, implementing
it is subtle and difficult to get right. But it only needs to be done
right once and then everyone benefits. Channel communication
is complicated too under the hood, but it's still a good abstraction.
Russ