On 29/11/2018 21.38, Jake Arkinstall wrote:
> In the case of ambiguities, the compiler can error as it currently does
> with ambiguous function overloads. But given the work that would go into
> making that happen, a deeper language change without the indirection
> through structs might be better.
>
> One thing I like about the struct idea is that it gives the control over
> named parameters to the API author, not to the user.
P1229 provides that.
> Another benefit I see is that we don't need a change to function
> mangling, whereas function calls with parameters of the same types
> but different names would require such a change.
I have an idea for 'function aliases' that would allow creating a
not-quite-overload¹ taking P1229 "strongly" named arguments that really
calls something else. (Usually, the "something else" would be the
ABI-existing version of the function that does not take "strongly" named
arguments.) The down side, however, is users can add such aliases, which
defeats your previous point. (OTOH, users can overload non-member
functions today, so you've already lost that battle. Possibly we could
limit method aliases to appearing in the class definition, which would
mitigate this to at least no worse than it is already.)
Basically, this gives you most of what everyone wants: opt-in, and the
ability to choose between name-based overloading and no ABI change.
(¹ The not-quite-overload mostly acts like an overload, except it is not
ambiguous with the signature it aliases.)
> We really need a poll to find out which named parameter features (and/or
> language changes) that people want, which features they don't want, and
> work from there. Otherwise what we end up with is many proposals and a
> different subset of people for and against each.
I actually started writing a paper to this effect, although it remains
to be seen if I actually finish it :-). (Basically, rather than being a
full proposal, the idea is to explain various folks' positions and
suggest how we can compromise... although the latter does end up being a
semi-proposal.)
> As an example, I will defend the notion of authors having control
> over whether or not their functions can be called with named
> parameters until I see evidence that a strong majority would prefer
> the user to have that control - at which point
> the position becomes indefensible from a standards perspective.
I'm on the fence here. In an ideal world, I agree, but I worry about
users wanting to use this feature with libraries that are unmaintained
or otherwise hard to change. That said, I don't think we can stop users
from adding overloads of free functions anyway...
--
Matthew