3 ms·
You can easily emulate break with conditional variable.
by vbezhenar 7y ago
You can easily emulate break with conditional variable.
- ainar-g 7y agoOf course, but wouldn't that effectively defeat the purpose of removing BREAK/EXIT in the first place? With something like: WHILE ~(lastIteration) & ~(Found(haystackPart, Needle)) DO (* Advance the haystackPart. *) END; I can at least say that after the loop if lastIteration is true, then the needle wasn't found in the haystack. While something like WHILE ~(found) DO (* Stuff. *) END; Conveys next to no information. To say nothing about the fact that the body of the loop will probably be full of: IF ~found THEN (* Stuff. *) END
- microtherion 7y ago> Of course, but wouldn't that effectively defeat the purpose of removing BREAK/EXIT in the first place? Personally, I do like having BREAK/EXIT, but in the eyes of structured programming purists, a loop with an explicit conditional still has a single entrance and single exit, while BREAK/EXIT statements destroy this property.