Date: Tue, 11 Aug 2020 16:16:12 +0000
Am Dienstag, den 11.08.2020, 09:04 -0700 schrieb Richard Smith:
> On Mon, 10 Aug 2020, 23:37 Uecker, Martin via Liaison, <
> liaison_at_[hidden]> wrote:
>
> >
> > Hi all,
> >
> > I recently proposed changes to the C grammar which got
> > voted into C2X by WG14 (N2508, also see N2496).
> >
> > This allows placing of labels everywhere in a compound
> > statement, even before declarations and at the end
> > of a block, which was not possible in C so far.
> >
> > Example:
> >
> > {
> > start:
> > int i;
> > mid:
> > int j;
> > end:
> > }
> >
> > It has been pointed out to me that while C++ allows
> > labels before declarations, it does not allow them
> > at the end of a compound statement.
> >
> > I plan to propose a change to C++ to make this
> > possible too and I wonder if you have any comments
> > or suggestions related to this?
> >
>
> Superficially this seems like a fairly minor quality
> of life improvement.
>
> But what about this:
>
> {
> if (a)
> label:
> }
>
> Does the if-statement end after the label? Or is that still a parse error?
> Neither option seems particularly nice to me.
This is still not allowed. Why is this not nice?
The following code is still allowed:
if (a)
label: foo();
Best,
Martin
> Another (old) difference between C is that in C++ you
> > can use declarations everywhere where statements are
> > allowed, which includes with iteration, control, and
> > jump statements.
> >
> > if (1)
> > int i;
> >
> > This does not make too much sense in the context
> > of C, so I do not think we will adopt this.
> >
> > Best,
> > Martin
> > _______________________________________________
> > Liaison mailing list
> > Liaison_at_lists.isocpp.org
> > Subscription: https://lists.isocpp.org/mailman/listinfo.cgi/liaison
> > Searchable archives: http://lists.isocpp.org/liaison/2020/08/index.php
> >
> On Mon, 10 Aug 2020, 23:37 Uecker, Martin via Liaison, <
> liaison_at_[hidden]> wrote:
>
> >
> > Hi all,
> >
> > I recently proposed changes to the C grammar which got
> > voted into C2X by WG14 (N2508, also see N2496).
> >
> > This allows placing of labels everywhere in a compound
> > statement, even before declarations and at the end
> > of a block, which was not possible in C so far.
> >
> > Example:
> >
> > {
> > start:
> > int i;
> > mid:
> > int j;
> > end:
> > }
> >
> > It has been pointed out to me that while C++ allows
> > labels before declarations, it does not allow them
> > at the end of a compound statement.
> >
> > I plan to propose a change to C++ to make this
> > possible too and I wonder if you have any comments
> > or suggestions related to this?
> >
>
> Superficially this seems like a fairly minor quality
> of life improvement.
>
> But what about this:
>
> {
> if (a)
> label:
> }
>
> Does the if-statement end after the label? Or is that still a parse error?
> Neither option seems particularly nice to me.
This is still not allowed. Why is this not nice?
The following code is still allowed:
if (a)
label: foo();
Best,
Martin
> Another (old) difference between C is that in C++ you
> > can use declarations everywhere where statements are
> > allowed, which includes with iteration, control, and
> > jump statements.
> >
> > if (1)
> > int i;
> >
> > This does not make too much sense in the context
> > of C, so I do not think we will adopt this.
> >
> > Best,
> > Martin
> > _______________________________________________
> > Liaison mailing list
> > Liaison_at_lists.isocpp.org
> > Subscription: https://lists.isocpp.org/mailman/listinfo.cgi/liaison
> > Searchable archives: http://lists.isocpp.org/liaison/2020/08/index.php
> >
Received on 2020-08-11 11:19:40