2 ms·
I argue for a "break" with a number that indicates how many loops you want to break out of. I have this in my programming language https://easylang.online https
by chkas 4y ago
I argue for a "break" with a number that indicates how many loops you want to break out of. I have this in my programming language https://easylang.online https://easylang.online. Each "break" needs the number, so also a "break 1".
for i = 1 to 50
for j = 1 to 50
if i * i + j * j * j = 80036
break 2
end
end
end
print i & " " & j
- ajanuary 4y ago1) I need to count the loops to work out where it breaks. 2) It’s sensitive to refactoring changing the nesting. That seems strictly worse than labelled breaks. What are the upsides?
- chkas 4y agoYou don't have to make up a name again. The namespace is usually pretty full anyway. If you accept a "break", which is a "break 1", you must consistently also allow a "break 2". Many things are sensitive to refactoring that changes the nesting.
- datalopers 4y agoPHP does this. Works fine, though it’s admittedly rarely needed in the first place.