4 ms·
What's poor about it, the numbers in the example? Think of them as inner/outer instead of "1" and "2". Without this kind of break statement, what do you do wh
by philsnow 1y ago
What's poor about it, the numbers in the example? Think of them as inner/outer instead of "1" and "2". Without this kind of break statement, what do you do when you want to exit the outer loop, something like this probably:
local stop = false
for i = 1, 10 do -- outer loop
if stop then break end
for j = 1, 5 do -- inner loop
break -- to break from inner loop
stop = true; break -- to break from outer loop
end
end
So this new feature fits with the general theme of pluto being a very-sugared lua.
- aa-jv 1y agoThis is just poor language design. The reason one might find this cumbersome or problematic, is in the case of very large numbers of lines of code - sure, your example is visible and somewhat readable (arguable) in its current form - but tell me you won't have issues when the loop is 80 or 100 lines of code, and you need to add another inner loop as part of the development process. Are you now going to go through and be sure all your breaks are numbered properly? Are you really, though? Better, imho, would have been to introduce labels and "break <label>", but even that is going to cause more headaches than its worth. Ultimately, one shouldn't write such horrid code anyway.
- philsnow 1y agoAh, well said on all points and i couldn't agree more.