This looks like it may wind up reinventing
select(2), for which one should maybe consult
poll(2) to see where that approach wound up.
The underlying problem is that Oberon lacks an unordered select (WHILE ELSIF comes close but has the unfortunate —in this case, but not for many actor scenarios— repetition). Maybe something could be done with a CASE Poll(...) OF ... END?
If life were a Ponyhof, I would ask for something along the lines of:
PROCEDURE sendit(text: STRING): BOOLEAN;
VAR fail: BOOLEAN;
FailChan: CHANNEL OF BOOLEAN;
BEGIN
fail := FALSE;
FailChan := After(TimeOut);
SELECT
SENDABLE(TxChan) THEN SEND(TxChan, text) |
RECEIVABLE(FailChan) THEN RECEIVE(fail, FailChan)
END
RETURN fail END sendit;
but that'd obviously be too large a change.