C++ Logo


Advanced search

Re: Flexible function parameters

From: Arthur O'Dwyer <arthur.j.odwyer_at_[hidden]>
Date: Thu, 9 Jul 2020 10:01:50 -0400
On Thu, Jul 9, 2020 at 9:32 AM Jake Arkinstall via Std-Proposals <
std-proposals_at_[hidden]> wrote:

> The why is clear.

FWIW, no it's not. The OP didn't give any reason for the new syntax at all.
In fact, the OP didn't even say what the new syntax is supposed to *do!*
What is `void f(int x, int y) {}` supposed to do differently from `void
f(int x; int y) {}` or `void f(int x: int y) {}`? Explaining *what the
change does* is an important part of any change request.

> It's a way of forming groupings of parameters, which currently isn't
> possible without bringing structs into the equation. This opens up some
> decent possibilities: Defaults can apply to the group (rather than having
> to put them at the end of the call), parameter packs can be logically
> separated in a way they currently cannot, and so we can pass multiple
> parameters to operator[] without interfering with the comma operator.

FYI, there's already a deploy plan in motion (to the admittedly limited
extent that WG21 can be said to make "deploy plans") to get multi-parameter
`operator[]` overloads. The first step in the plan was committed in C++20:
The second step, targeted for C++23, is to support overloaded
`operator[](int x, int y)` (or whatever parameter types) with the natural
meaning and call syntax.
The goal and justification, targeted also for C++23 as far as I know, is to
finally ship `mdspan`. (Which I personally think is a silly end goal, but
there seem to be a lot of people looking forward to it just as a lot of
people look forward to C++20's `span`.)


Received on 2020-07-09 09:05:18