C++ Logo

std-proposals

Advanced search

Re: [std-proposals] "once" keyword

From: Arthur O'Dwyer <arthur.j.odwyer_at_[hidden]>
Date: Wed, 24 May 2023 10:50:54 -0400
On Wed, May 24, 2023 at 10:36 AM LUCE Jean-Sébastien via Std-Proposals <
std-proposals_at_[hidden]> wrote:

> Yes this was why I talked about another keyword, changing "if" behaviour
> (with break) would create big mess with all existant c++ code.
>
> I agree with most of our comments, yet I still found "goto" syntax not
> ideal.
>
> And found it strange to have no "return" equivalent in a sub part of a
> function.
>

You've hit the nail on the head. One of the big ideas of the "structured
programming" revolution of the '60s–'70s was *functional decomposition*:
the idea that if your program is doing more than one "thing," you should
break it down into smaller functions where each function accomplishes just
one "thing." Every time you find yourself needing "the equivalent of
`return` but for a smaller part of a *foo*," structured
programming's answer is always going to be: *Break that foo down into
smaller functions, and then use `return`.*

`return` is the `return` you're looking for. :)

–Arthur

Received on 2023-05-24 14:51:07