Date: Fri, 17 Feb 2023 09:56:48 -0500
On Fri, Feb 17, 2023 at 9:51 AM Hypatia (of) Sva via Std-Proposals <
std-proposals_at_[hidden]> wrote:
> Hello,
>
> Actually, I had an example of that. The algorithm was the Smith normal
> form of an integer matrix, and I had to add / subtract columns from each
> other until the gcd was in the pivot position a[i][i]. The short form of
> the algorithm is like this:
>
> First, Make sure a[0][0] isnt 0; if the whole matrix is 0, return,
> otherwise swap columns / rows
> The main loop: subtract the first column/row from the others as much as
> possible while staying positive (so subtract the column a[i][0] idiv
> a[0][0] times). If for any now a[i][0] or a[0][i] is smaller than
> a[0][0] (i.e. a[i][0] % a[0][0] > 0), then swap the columns, _and begin
> the loop again_!
> This means, inside the loop going over the rows / columns, you have to
> restart, effictively you have
>
> for(;;)
> outer: {
> for(row: rows) {
> transform();
> if(necessary) {
> swap_rows(row,0);
> continue outer;
> }
> }
> //the same with columns.
> }
>
I don't quite understand this code.
- If `continue outer;` means "continue the `for (row: rows)` loop," then
it's equivalent to `continue;`.
- If `continue outer;` means "continue the `for(;;)` loop," then it's
equivalent to `goto outer;`.
Either way, it seems that we have a dedicated syntax for this already.
I don't think this proposal is worth pursuing anyway (I encourage you to
google "labeled break continue C++ proposals" to see all the older work in
this area). But if anyone *were* amenable to being convinced by a single
example, it seems to me that this wouldn't be the example to show them —
because (unless I'm misunderstanding the intent of the code) this is
actually a perfect example of C++'s existing syntax sufficing just fine in
practice. It seems to show the exact *opposite* of motivation for this
proposal.
–Arthur
std-proposals_at_[hidden]> wrote:
> Hello,
>
> Actually, I had an example of that. The algorithm was the Smith normal
> form of an integer matrix, and I had to add / subtract columns from each
> other until the gcd was in the pivot position a[i][i]. The short form of
> the algorithm is like this:
>
> First, Make sure a[0][0] isnt 0; if the whole matrix is 0, return,
> otherwise swap columns / rows
> The main loop: subtract the first column/row from the others as much as
> possible while staying positive (so subtract the column a[i][0] idiv
> a[0][0] times). If for any now a[i][0] or a[0][i] is smaller than
> a[0][0] (i.e. a[i][0] % a[0][0] > 0), then swap the columns, _and begin
> the loop again_!
> This means, inside the loop going over the rows / columns, you have to
> restart, effictively you have
>
> for(;;)
> outer: {
> for(row: rows) {
> transform();
> if(necessary) {
> swap_rows(row,0);
> continue outer;
> }
> }
> //the same with columns.
> }
>
I don't quite understand this code.
- If `continue outer;` means "continue the `for (row: rows)` loop," then
it's equivalent to `continue;`.
- If `continue outer;` means "continue the `for(;;)` loop," then it's
equivalent to `goto outer;`.
Either way, it seems that we have a dedicated syntax for this already.
I don't think this proposal is worth pursuing anyway (I encourage you to
google "labeled break continue C++ proposals" to see all the older work in
this area). But if anyone *were* amenable to being convinced by a single
example, it seems to me that this wouldn't be the example to show them —
because (unless I'm misunderstanding the intent of the code) this is
actually a perfect example of C++'s existing syntax sufficing just fine in
practice. It seems to show the exact *opposite* of motivation for this
proposal.
–Arthur
Received on 2023-02-17 14:57:02