C++ Logo

liaison

Advanced search

Re: [wg14/wg21 liaison] Multidimensional subscript operator

From: Jens Gustedt <jens.gustedt_at_[hidden]>
Date: Mon, 26 Apr 2021 20:49:47 +0200
Philipp,

on Mon, 26 Apr 2021 20:05:25 +0200 you (Philipp Klaus Krause via
Liaison <liaison_at_[hidden]>) wrote:

> Am 26.04.21 um 13:18 schrieb Jens Maurer via Liaison:
> >>
> >> postfix-expression [ expression ]
> >>
> >> to
> >>
> >> postfix-expression [ assignment-expression ]
> >>
> >> Such a change would be better in line with the function operator,
> >> for example, that also only has assignment-expression, here.
> >
> > Sounds good, if WG14 is happy with the backward compatibility break
> > here.
>
> Making formerly correct code (i.e. using a comma operator in a array
> index) illegal for something that as far as I see, basically is just
> syntactic sugar (a[i,j] vs a[i][j]) doesn't look like something
> WG14-like to me.

My argument would basically not be that it would be preparing for
multi-indices (yes that's just syntactic surgar from a POV of C) but
to catch bugs. As said, many compilers warn on that, anyhow, so this
seems to be a commonly acknowledged loop hole.

I would propose to think about selection statements and maybe
iteration statements at the same time. Here also we have "expression"
as the controlling expression. If we could just use
"condional-expression" for these? That would avoid our users the
hussle with simple assignment that is taken for an equality operator
and a comma operator that is used instead of logical conjunction.

Jā‚‘ā‚™ā‚›G

-- 
:: 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-26 13:49:55