Re:C/C++ vs. Rust Performance
by dehrmann on Sunday November 01, 2020 @03:18PM
(#24962149)
The only times I've really wanted goto were around exception handling. Java (not sure if it started there or was borrowed) actually has a construct that can do this without the issues with goto:
[ Parent
| on HN ]
Rust has this innovative feature called "functions" which enables you to break from any block by just giving it a name and using "return". It can even return a value!
(/s obviously, but also not /s obviously. The serious point here may be that Java or whatever got in the way of defining functions by requiring them to be "methods" stuck in a "class" rather than, you know, just functions.)
A static function in Java is essentially just a function. Also I have no idea what functions being associated with classes has to do with breaking out of loops.
encapsulate your nested loops in a function and return to exit multiple loops at the same time. Having nested lightweight functions allows minimal syntactical overhead compared to plain loops, although still not zero.