Liste des Groupes | Revenir à cl c |
On Fri, 13 Dec 2024 11:12:13 +0000Some might say "overkill" - others would say that if C first gains a powerful feature that can be useful in many contexts, then multi-level break is unnecessary. I would not imagine adding lambdas to the language /solely/ for this use-case!
bart <bc@freeuk.com> wrote:
>Agreed.
>
Some people don't like ordinary break either. There you could also
suggest using convoluted logic, or using a function instead But here
'break' would be clearly be simpler and easier.
>
(I'd like to see a lambda example that is simpler than a two-levelIt would not be simpler than goto, but a little easier to follow.
break or even a goto.)
>
Relatively to two-level break, it's more general. Suppose, you have 3
levels of nested loops. Two-level break does not help for breaking
out of innermost loop *into* outermost loop.
The problem with lambda in this role is that it would be an overkill.
Also if one wants simplicity of writing then David's suggestion forI did not suggest lambdas without captures - I suggested lambdas with the restriction that closure objects would not be needed. In particular, as long as the lambda is only ever used within the lifetime of any variables it captures by reference, no closure object is ever needed.
lambda without capture is not sufficient. On the other hand, lambda
with capture of full environment by reference is very easy to write,
but potentially very hard to follow and error-prone.
I am strictly inclined to think that goto is better than all
alternatives proposed so far.
I've had a quick look through my codebases (not C), and I couldn'tFor the reason explained above I don't like 'break all' idea.
see an example of a numbered break. All I could find was the
equivalant of:
>
break # the vast majority
break all
>
The latter breaks out of the outermost loop.
>
Les messages affichés proviennent d'usenet.