Date: Thu, 19 Dec 2024 12:24:40 +0000
Well, I would argue that different languages have different syntax (that’s what makes them different languages).
It doesn’t bother me if C++ has different syntax, we are not trying to make all languages inter-compatible.
I think it’s a trap to just look at “whatever someone else is doing” and just go with that as opposed to just figuring out what’s actually best for the language.
Case in point, many of the cited languages either don’t do control flow in this way, or don’t have a “goto” statement, thus would never have to suffer this problem
From: Std-Proposals <std-proposals-bounces_at_lists.isocpp.org> On Behalf Of Sebastian Wittmeier via Std-Proposals
Sent: Thursday, December 19, 2024 12:54 PM
To: std-proposals_at_[hidden]
Cc: Sebastian Wittmeier <wittmeier_at_[hidden]>
Subject: Re: [std-proposals] Bringing break/continue with label to C++
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.
It doesn’t bother me if C++ has different syntax, we are not trying to make all languages inter-compatible.
I think it’s a trap to just look at “whatever someone else is doing” and just go with that as opposed to just figuring out what’s actually best for the language.
Case in point, many of the cited languages either don’t do control flow in this way, or don’t have a “goto” statement, thus would never have to suffer this problem
From: Std-Proposals <std-proposals-bounces_at_lists.isocpp.org> On Behalf Of Sebastian Wittmeier via Std-Proposals
Sent: Thursday, December 19, 2024 12:54 PM
To: std-proposals_at_[hidden]
Cc: Sebastian Wittmeier <wittmeier_at_[hidden]>
Subject: Re: [std-proposals] Bringing break/continue with label to C++
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 12:24:45