C++ Logo

std-proposals

Advanced search

Re: [std-proposals] Bringing break/continue with label to C++

From: Sebastian Wittmeier <wittmeier_at_[hidden]>
Date: Thu, 19 Dec 2024 12:54:04 +0100
Scala offers breakable https://www.scala-lang.org/api/2.13.3/scala/util/control/Breaks.html breakable { for (x <- xs) { if (done) break() f(x) } } based on a customizable control structure PHP offers a numeric argument https://www.php.net/manual/en/control-structures.break.php $i = 0; while (++$i) { switch ($i) { case 5: echo "At 5<br />\n"; break 1; /* Exit only the switch. */ case 10: echo "At 10; quitting<br />\n"; break 2; /* Exit the switch and the while. */ default: break; } } All other old and new languages seem to define a label just in front of the control flow instruction. Including sophisticated ones (lots of control structures) like Raku: https://docs.raku.org/language/control OUTAHERE: loop ( my $i = 1; True; $i++ ) { OUTFOR: for 1,2,3 -> $n { # exits the for loop before its natural end last OUTFOR if $n == 2; } # exits the infinite loop last OUTAHERE if $i >= 2; } So one can call it an industry-standard.  

Received on 2024-12-19 11:56:18