| ▲ | kibwen 2 days ago |
| I wouldn't call Rust "a big language" because of labeled break. This is a pretty standard language feature, you can do the same in C (and therefore C++), Go, Javascript, Java, C#... |
|
| ▲ | atq2119 2 days ago | parent [-] |
| Those languages don't treat blocks as expressions, so you really can't do the same thing there. Something very similar, yes. But not the same. |
| |
| ▲ | kibwen 2 days ago | parent [-] | | Those languages aren't expression-oriented, so you would need to assign the result to a previously-initialized variable in a higher scope. But that just makes this pattern clunkier in those languages. This subthread is about jumping to labels, which is a relatively obscure yet widespread feature supported by many languages (though C and Go allow forward jumps, and the rest only allow backward jumps, since the latter ensures that control flow does not become irreducible). |
|