> What if we did without the timer variable?
sure. as you say, it's pretty much equivalent. the only thing that
troubles me is that the Occam version uses absolute timestamps, where
yours are relative.
when dealing with short intervals of time, given that scheduling is
somewhat arbitrary, the difference between:
# do something every microsecond (relative timeout)
for(;;){
alt{
timeout 1 =>
# do something
}
}
and:
# do something every microsecond (absolute timeout)
t := now();
for(;;){
alt{
timeout t =>
# do something;
t++;
}
}
might be significant. the former version allows errors to accumulate,
where the latter does not. having calculated the timeout necessary
for the alt, you never know exactly when it is going to acually start;
a relative timeout is inevitably inaccurate.
i think that might be one of the reasons why the transputer folks (who
thought quite hard about things) chose absolute over relative timeouts.
> 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.
i agree totally. this was my motivation in posting.