C++ Logo

liaison

Advanced search

Re: [wg14/wg21 liaison] (SC22WG14.19237) grammar incompatibilities with lambdas

From: Jens Gustedt <jens.gustedt_at_[hidden]>
Date: Mon, 12 Apr 2021 10:32:57 +0200
Javier,

on Sun, 11 Apr 2021 21:45:06 +0200 (CEST) you ("Javier Múgica"
<javier_at_[hidden]>) wrote:

> I certainly prefer a single token for [[. Pretending it is two
> tokens... well, you already explained the problems.

Thanks for the feedback!

> On the other hand, ]] can appear in a valid program. Could it be
> defined that a sequence of two consecutive ']' is a single token if
> it matches a preceding [[ token?

No, I don't think we should. That would just complexify the
grammar. The main difficulty of C++' grammar with `< >` template
brackets is actually that `>>` is already the right-shift token.
There is no need to artificially introduce the same problem here.

But I should have said that explicitly:

    - introduce a `[[` for attribute opening
    - leave the token pair `]` `]` alone, since this occurs in
      valid code

It is a bit unfortunate that this is not symmetric, but that is more
an aesthetic question than anything else.

> (For those of you who work / have worked in
> tokenzing C code). It seems a parser need not even keep a count of
> unmatched [[ tokens, just look ahead for the closing ]], since a ]]
> sequence cannot appear within an [[ attribute ]], can it?
>
> > The only impact for users of C23 would be that when they want to
> > use a lambda in an array bound (which is a new feature) they'd have
> > to put spaces between the `[` `[`.
>
> I'd certainly cope with this than have [[ not a single token. Just as
> '>' '>' for templates in C++.

Yes that would be my hope, too.

BTW, at the time we voted this I had a more complete solution for C

    http://www.open-std.org/jtc1/sc22/wg14/www/docs/n2175.pdf

This has encountered full resistance from the Unicode-illiterate and I
don't think that it has been really considered seriously.

It still would be a much cleaner solution.

Thanks
Jens

-- 
:: INRIA Nancy Grand Est ::: Camus ::::::: ICube/ICPS :::
:: ::::::::::::::: office Strasbourg : +33 368854536   ::
:: :::::::::::::::::::::: gsm France : +33 651400183   ::
:: ::::::::::::::: gsm international : +49 15737185122 ::
:: http://icube-icps.unistra.fr/index.php/Jens_Gustedt ::

Received on 2021-04-12 03:33:29