var news;
waitfor {
news = http.get("http://news.bbc.co.uk");
}
or {
hold(1000);
news = http.get("http://news.cnn.com");
}
or {
hold(1000*60);
throw "sorry, no news. timeout";
}
show(news);
This starts the first 'or' clause the moment the http.get(BBC) suspends, which it does quickly because http.get is async. Now, if the BBC get returns just after my hold(1000) has completed but before http.get(CNN) had the time to really launch the http request and suspend, i'll have done the CNN get for nothing.Of course in this case this only means a wasted request. But what in case of side effects?