Date: Thu, 6 Jan 2022 10:21:56 +0100
On 2022-01-06 at 05:28, 柳田達也 via Std-Proposals wrote:
> I would like to propose new separator for arguments as shown below:
>
> void func(int a; int b); // not "," but ";"
>
> The motivation to add this feature is that multidimensional subscript
> operator in P2128R3 (
> http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2021/p2128r3.pdf
> <http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2021/p2128r3.pdf> )
> may cause confusion.
> If subscript operator could take multiple arguments, there could be two
> types of usages.
> The first usage is multidimensional access as explained in P2128R3 and
> the second one is subrange access as follows:
>
> class MyVector {
> std::vector<int> vec;
> public:
> MyVector(std::vector<int>&& v) : vec(std::move(v)) {}
>
> MyVector operator[](int a, int b) const { // returns subrange
> auto it = vec.begin();
> return MyVector(std::vector<int>(it + a, it + b));
> }
> };
>
> I think this is confusing and probably occurs many bugs.
> Thus, to make it clear at a glance will help avoiding bugs.
> My proposal is to rule implicitly that array[0, 1] should be a subrange
> access and array[0; 1] implies multidimensional access.
Definitely not "clear at a glance". The presence or absence of the
little dot is way too subtle, especially for older guys like me with
failing eyesight.
I have previously done work in COBOL, where "statements" are collected
into "sentences", and each sentence is terminated by a period (just like
in normal language).
The coding rules were very clear that you were only allowed to have one
period per section of code, and it had to be at the end. A single period
in the middle of a code section was way to easy to miss!
I don't think it is a good idea to introduce a similar subtlety into C++.
> I would like to propose new separator for arguments as shown below:
>
> void func(int a; int b); // not "," but ";"
>
> The motivation to add this feature is that multidimensional subscript
> operator in P2128R3 (
> http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2021/p2128r3.pdf
> <http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2021/p2128r3.pdf> )
> may cause confusion.
> If subscript operator could take multiple arguments, there could be two
> types of usages.
> The first usage is multidimensional access as explained in P2128R3 and
> the second one is subrange access as follows:
>
> class MyVector {
> std::vector<int> vec;
> public:
> MyVector(std::vector<int>&& v) : vec(std::move(v)) {}
>
> MyVector operator[](int a, int b) const { // returns subrange
> auto it = vec.begin();
> return MyVector(std::vector<int>(it + a, it + b));
> }
> };
>
> I think this is confusing and probably occurs many bugs.
> Thus, to make it clear at a glance will help avoiding bugs.
> My proposal is to rule implicitly that array[0, 1] should be a subrange
> access and array[0; 1] implies multidimensional access.
Definitely not "clear at a glance". The presence or absence of the
little dot is way too subtle, especially for older guys like me with
failing eyesight.
I have previously done work in COBOL, where "statements" are collected
into "sentences", and each sentence is terminated by a period (just like
in normal language).
The coding rules were very clear that you were only allowed to have one
period per section of code, and it had to be at the end. A single period
in the middle of a code section was way to easy to miss!
I don't think it is a good idea to introduce a similar subtlety into C++.
Received on 2022-01-06 03:22:20