3 ms·
> I like having a few different loops to keep code more readable. When they have similar semantics, and are not arbitrarily designed. In Oberon: - while has
by illiarian 4y ago
> I like having a few different loops to keep code more readable.
When they have similar semantics, and are not arbitrarily designed.
In Oberon:
- while has an elseif statement. Repeat is a do/while, doesn't have an elseif statement
- loop is allowed an exit. No other loops are allowed to terminate early. And that is literally the only reason loop exists
etc.
- layer8 4y agoThe last point is very likely by design: Only when you see a LOOP do you have to worry about early exits. For the other, more common constructs, you instantly know there won’t be an exit somewhere in the middle, and you can reason about its termination behavior solely based on the loop conditional.
- illiarian 4y agoIt's not by design, not really. Early Pascal/Modula/Oberons were extremely anal about loops (of any kind) never having any early exits, ever. Then they ran into the real world. So each consecutive version of Oberon either added early returns or removed early returns. Sometimes like clockwork. And also added/removed other types of loops in pursuit of some unspecified ideal of simplicity. You can see part of that history in the overview of differences: https://oberon-lang.github.io/2021/07/16/comparing-oberon+-with-oberon-2-and-07.html https://oberon-lang.github.io/2021/07/16/comparing-oberon+-w... So it's a self-imposed constraint that makes very little sense.