220 39815 <CAPuuy5d7ZxTzoV+FaXrM0zd-QrDwctDWRPO_t002PQgHvwF07A@mail.gmail.com> article
Path: news.gmane.org!.POSTED!not-for-mail
From: Justin Bassett <jbassett271@gmail.com>
Newsgroups: gmane.comp.lang.c++.isocpp.proposals
Subject: Re: Named Parameters for C++
Date: Wed, 15 Aug 2018 23:33:55 -0700
Lines: 354
Approved: news@gmane.org
Message-ID: <CAPuuy5d7ZxTzoV+FaXrM0zd-QrDwctDWRPO_t002PQgHvwF07A@mail.gmail.com>
References: <CAPuuy5eBx1ybcPjS6dNsk7n1_c2uhdRBS19qr=q5cj3cTURnLQ@mail.gmail.com>
 <CALmDwq05u+vxQ2nd+oeEhws1s6Ew3Z5ZkSnGoiMh5XXVDKjUMQ@mail.gmail.com>
Reply-To: std-proposals@isocpp.org
NNTP-Posting-Host: blaine.gmane.org
Mime-Version: 1.0
Content-Type: multipart/alternative; boundary="00000000000049578b057387a1b7"
X-Trace: blaine.gmane.org 1534401124 6565 195.159.176.226 (16 Aug 2018 06:32:04 GMT)
X-Complaints-To: usenet@blaine.gmane.org
NNTP-Posting-Date: Thu, 16 Aug 2018 06:32:04 +0000 (UTC)
To: std-proposals@isocpp.org
Original-X-From: std-proposals+bncBC5PL3NYWEDBBYFV2TNQKGQEZQTVSBQ@isocpp.org Thu Aug 16 08:32:00 2018
Return-path: <std-proposals+bncBC5PL3NYWEDBBYFV2TNQKGQEZQTVSBQ@isocpp.org>
Envelope-to: gclcip-std-proposals@m.gmane.org
Original-Received: from mail-oi0-f72.google.com ([209.85.218.72])
	by blaine.gmane.org with esmtp (Exim 4.84_2)
	(envelope-from <std-proposals+bncBC5PL3NYWEDBBYFV2TNQKGQEZQTVSBQ@isocpp.org>)
	id 1fqBp8-0001YM-QJ
	for gclcip-std-proposals@m.gmane.org; Thu, 16 Aug 2018 08:31:59 +0200
Original-Received: by mail-oi0-f72.google.com with SMTP id v205-v6sf3387384oie.20
        for <gclcip-std-proposals@m.gmane.org>; Wed, 15 Aug 2018 23:34:09 -0700 (PDT)
ARC-Seal: i=2; a=rsa-sha256; t=1534401249; cv=pass;
        d=google.com; s=arc-20160816;
        b=Mwf0rc3WBL0NVnI6cdSOxZEEo09uC1Thcm9f8xnGm/jTiuXfgR7dNMxAp3ux8o9WEl
         YDyPT72LZBoSDVcLesRSzO7+Thuc3cDoURWRiInj4BgAbcWR7IOhTy7NcpY1w+6CiO7A
         2bPphs0MxgWATdfxhhgo/QNjvfbwX41Rg15sueK6jEnFghgnlnW8YhaDG6y3RD/N2TEP
         b8R9Iz864T7qS/OO658l+O6Gr/AQR+rNddrwW7Iclk/wTdgrl8GARrMLmE/oiuPDYrUw
         jLXr5dPOAFGNjpQO94ZXu2oG8K59zY1Y8yZJqLVCoH8LJdnmZEeF4+SglGOnPRKxvuNg
         NuNw==
ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816;
        h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post
         :list-id:mailing-list:precedence:reply-to:to:subject:message-id:date
         :from:in-reply-to:references:mime-version:arc-authentication-results
         :arc-message-signature:dkim-signature:arc-authentication-results;
        bh=4D9Yx7eKZkhcXbZd3Zik2cnkt6endApHiWJe7Gu6QLk=;
        b=k4dc4JQTn9K9DxhsWQOn1Xf8FN/yF4qD6ygLChGFvkZ7lieIlL7HQz8jbrK8DPyD1z
         P+XSnAMjEuTkhnNDDlK0IfZ9mLEq8TukBPd3m9D+l88BMbJIf2CbHEW0W4Fyc7anDA1o
         BZ8XjogOC6955qMVguYF98e5RrPRCNZ/SVGdoXuEMJB+6DdVWSSqtr0g6pUMGD/pDdv5
         FMlNOvEewTLr9DbbJ4s4T+5tT73qgksmnnXesZ/lyAlIVJ7c7d4OGDflAB3htjaj4WxJ
         0p4rK/schdTgV1oP3cLnMLMwAl7Tp75Oa46QUMz2hl8sAnXZzj97bJ4RLRUBaJLkyqgQ
         zsAQ==
ARC-Authentication-Results: i=2; mx.google.com;
       dkim=pass header.i=@gmail.com header.s=20161025 header.b=aeVIjcni;
       spf=pass (google.com: domain of jbassett271@gmail.com designates 209.85.220.41 as permitted sender) smtp.mailfrom=jbassett271@gmail.com;
       dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=isocpp-org.20150623.gappssmtp.com; s=20150623;
        h=mime-version:references:in-reply-to:from:date:message-id:subject:to
         :x-original-sender:x-original-authentication-results:reply-to
         :precedence:mailing-list:list-id:list-post:list-help:list-archive
         :list-subscribe:list-unsubscribe;
        bh=4D9Yx7eKZkhcXbZd3Zik2cnkt6endApHiWJe7Gu6QLk=;
        b=B3kNZJLa5KGmJkDkrdhETn503gU6v5ArdnO4dqnoM33l8CMhG8Lra8XvM2VpZ5kD7x
         87Cue08AqIkZkwwCISIopG5umjNDCQdP9uIaIAu6c9JWPKJNUDGSOYwoG9beZ5U1wWZe
         1sE9Z84t2qtxq+ejzHiZGQTd3OSPmwE8r+zkjLaQrBzwP3TI4mNHoyQ2TvJ5fdTCe5jt
         ZefHi3NXS3h88dgRDjiKUz+RJWMZItMoFMGbOkb10cteJZxf9X3D0XrUGozcMyjbjaob
         R5N6XBoBneGTBzc++1NxzPIoK0cSnSJPbj3qdCNRNJSw+lnlgQEfdlORsHTtkdmIFN9G
         l1LA==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20161025;
        h=x-gm-message-state:mime-version:references:in-reply-to:from:date
         :message-id:subject:to:x-original-sender
         :x-original-authentication-results:reply-to:precedence:mailing-list
         :list-id:x-spam-checked-in-group:list-post:list-help:list-archive
         :list-subscribe:list-unsubscribe;
        bh=4D9Yx7eKZkhcXbZd3Zik2cnkt6endApHiWJe7Gu6QLk=;
        b=YytoeIIRqkuhH+5dzR6fXZBAT3ZlEGNry5zVv1ZR93mc/2AGpBG1iOv8amGD4SPnEu
         fnFo4GORegpy+WDtaFaCrqV9sn9v2oto8dmi+keZmicgSvpvqurx1N/S93EVMRWRexFC
         r+QSCIdpEgEOGlRYVWIfljzEF3dfeSV7lWIMsyfMC2k3u/Ijw2Pcg1bFmcbJgK5lL0uA
         BUYzf6U+aQy/xBS7SJZ21jOTdJAmLi3i9WmNcOIvc64MT17Yn3spCShzJxOVpBgv6h+M
         cI3Gtuf8EQkYpkSwX7GEnElaXHewNydFrtI4WzvfQJeqOxgxKGA6/J2/F3bZt10d5AYl
         8NxA==
X-Gm-Message-State: AOUpUlGhHLz/s6F7qWvB8KtKHrZu9JJ43e3mosq85AfLaaICo0OaS92V
	uSW3nrUTqwHQSgSvoG4JQrOElA==
X-Google-Smtp-Source: AA+uWPx7sPB8DxhRkGJsmJ3HIUXCKH7/bilLEIOWK6u/IqJBEaQQP19zPGwFlesFU2bLHfdwOrd9hw==
X-Received: by 2002:aca:dc09:: with SMTP id t9-v6mr17214652oig.73.1534401248872;
        Wed, 15 Aug 2018 23:34:08 -0700 (PDT)
X-BeenThere: std-proposals@isocpp.org
Original-Received: by 2002:aca:2819:: with SMTP id 25-v6ls2031067oix.23.gmail; Wed, 15
 Aug 2018 23:34:07 -0700 (PDT)
X-Received: by 2002:aca:c602:: with SMTP id w2-v6mr32062792oif.122.1534401247775;
        Wed, 15 Aug 2018 23:34:07 -0700 (PDT)
ARC-Seal: i=1; a=rsa-sha256; t=1534401247; cv=none;
        d=google.com; s=arc-20160816;
        b=QMPPpWwAXKPEnmy+O2BQxyGHNUd8xqlYQmQkew550UQHvWALT2fKapMjOqcrIiGVFu
         GaUYkpn/VrY11Y87EqWbXqSJan0WzSN9Jmcb/mtfObdvROcGcy/1VNcoKxQ+w8gz7bOc
         FWotzQUdJrdcvnC7S+9zJ9EkheWgAu4JNfK49wsSCbdeKqZp1E48IqXOuLKYH0hlj16/
         IUTEq7r3WHNDT6L0JFFGR6Hee/HBErRlNx3ueLE0UxOdNP9wWEEwRPkZUUnYcBG2Tphm
         Me47kmMpxzjdUETwtwBv3aNmLlZJKmLn8JxmGIPB1qoz/JXmiz/rnDZQa+fJZ0POJXaU
         1ctw==
ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816;
        h=to:subject:message-id:date:from:in-reply-to:references:mime-version
         :dkim-signature:arc-authentication-results;
        bh=NY/HHCVnGUdEqRewsfojpse2Wqes9sR8OhLX2m1bx7A=;
        b=d5zyIiCL/peWR7nUQUdWxTB8/bFb7V4qWULLoUTO3tscyUTs7uU1l2+Yp4HZcq9J9Q
         wo1CbxRauCs1+FeR0J+Nl5wIkulVXAQUi6vRpv+5SgNghPbcPWS9cuq5tQCW+mUyUqUc
         neF11+mDMwWNvBqpu3a6VqHhRmKUwboaVWNnAWvgzNaYKswaqXE250YumfdqQjlxrkAT
         tVQHcGDaMGTm6SDrx/b0m2QoX3X+/8C4p8U6Ipgpp+6ESCtsxeVAnZECwEvOA1sysZ58
         t7x2eWExGcIeU4Ip+DgDiqZmYrbTKtMkWt5qzcIdMTU0x7grajOyZBPoxKi/zJxEfI0W
         0Niw==
ARC-Authentication-Results: i=1; mx.google.com;
       dkim=pass header.i=@gmail.com header.s=20161025 header.b=aeVIjcni;
       spf=pass (google.com: domain of jbassett271@gmail.com designates 209.85.220.41 as permitted sender) smtp.mailfrom=jbassett271@gmail.com;
       dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com
Original-Received: from mail-sor-f41.google.com (mail-sor-f41.google.com. [209.85.220.41])
        by mx.google.com with SMTPS id q203-v6sor13675828oib.240.2018.08.15.23.34.07
        for <std-proposals@isocpp.org>
        (Google Transport Security);
        Wed, 15 Aug 2018 23:34:07 -0700 (PDT)
Received-SPF: pass (google.com: domain of jbassett271@gmail.com designates 209.85.220.41 as permitted sender) client-ip=209.85.220.41;
X-Received: by 2002:aca:f0d4:: with SMTP id o203-v6mr31175408oih.21.1534401247269;
 Wed, 15 Aug 2018 23:34:07 -0700 (PDT)
In-Reply-To: <CALmDwq05u+vxQ2nd+oeEhws1s6Ew3Z5ZkSnGoiMh5XXVDKjUMQ@mail.gmail.com>
X-Original-Sender: jbassett271@gmail.com
X-Original-Authentication-Results: mx.google.com;       dkim=pass
 header.i=@gmail.com header.s=20161025 header.b=aeVIjcni;       spf=pass
 (google.com: domain of jbassett271@gmail.com designates 209.85.220.41 as
 permitted sender) smtp.mailfrom=jbassett271@gmail.com;       dmarc=pass
 (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com
Precedence: list
Mailing-list: list std-proposals@isocpp.org; contact std-proposals+owners@isocpp.org
List-ID: <std-proposals.isocpp.org>
X-Spam-Checked-In-Group: std-proposals@isocpp.org
X-Google-Group-Id: 399137483710
List-Post: <https://groups.google.com/a/isocpp.org/group/std-proposals/post>, <mailto:std-proposals@isocpp.org>
List-Help: <https://support.google.com/a/isocpp.org/bin/topic.py?topic=25838>, <mailto:std-proposals+help@isocpp.org>
List-Archive: <https://groups.google.com/a/isocpp.org/group/std-proposals/>
List-Subscribe: <https://groups.google.com/a/isocpp.org/group/std-proposals/subscribe>,
 <mailto:std-proposals+subscribe@isocpp.org>
List-Unsubscribe: <mailto:googlegroups-manage+399137483710+unsubscribe@googlegroups.com>,
 <https://groups.google.com/a/isocpp.org/group/std-proposals/subscribe>
Xref: news.gmane.org gmane.comp.lang.c++.isocpp.proposals:39815
Archived-At: <http://permalink.gmane.org/gmane.comp.lang.c++.isocpp.proposals/39815>

--00000000000049578b057387a1b7
Content-Type: text/plain; charset="UTF-8"

On Wed, Aug 15, 2018 at 10:55 PM Nicolas Lesser <blitzrakete@gmail.com>
wrote:

> For declaring a function with named parameters, it is imperative that it
>> is opt-in, otherwise, functions parameter names become part of the public
>> API of the function, which is undesirable
>
>
> Pardon my ignorance, but why exactly is this undesirable? Designated
> initializer lists are also not opt-in. I don't really see a problem with
> this. I can't imagine function parameters to change once they're the
> function is part of the API.
>

Consider all the standard library functions. Suddenly all the parameter
names become public. Here's an example from this reddit thread (
https://www.reddit.com/r/cpp/comments/5mdes5/what_happened_to_the_named_parameter_proposal/
):

std::max(._Left = 1, ._Right = 2)

Those names are not intended to be public. They are named strangely like
this to avoid problems with user defined macros. We *could *standardize
names for every function in the standard, but I believe that is a lot of
work.

Also, that would make parameter names part of the API by default. I believe
library authors would like the opt-in design, as it makes it much easier to
make API compatible changes. Names used as function parameters are not
generally expected to be part of the API. Especially considering that there
is a lot of code already written which assumes that the parameter names are
not part of the API. If we suddenly change it to be part of the API, the
library authors had no say in whether those names should be part of the API.


> There should be some way to specify that the parameter is name-only. For
>> example, altering Python's implementation
>> <https://www.python.org/dev/peps/pep-3102/>:
>>
>> // anything after the . is name-only
>> int foo(., int .x);
>>
>> Default arguments should be able to work as they are now.
>>
>
> I disagree with your proposed solution. Name-only parameters naturally
> appear when they are after a varadic ("catch-all") parameter, just like in
> Python's implementation.
>

Good point. I don't disagree with this, but I didn't like having to specify
the types for the variadic template pack. Note that PEP 3102, which I
linked to, allows Python to leave off the name for the variadic parameter.
I was imagining something like that


> template <typename ...T>
> void f(T ..., int name);
>
> f(.name = 1); // name-only argument
>
> Now you have a small problem: C's variadic parameters are specified in the
> grammar itself to come last, which can be changed but would require some
> restructuring. But I don't think it's worth supporting them.
>

I agree here. If supporting C's varargs is difficult in this case, I don't
consider it a big drawback to disallow them when a function has named
parameters.


> However, I believe that the name should be part of the function type and
>> should be mangled into the name for the function. It should not be allowed
>> for the following two declarations to coexist:
>>
>> int foo(int .x, int .y);
>> int foo(int .a, int .b);
>>
>> If the name of the parameters are not part of the function, then if those
>> declarations are in separate translation units, there's little way to
>> enforce that this should fail to compile / link.
>>
>
> Any reasons to disallow this? I mean, this is already possible:
>

My first reason for doing so was to directly address concerns in a reddit
thread asking about a previous named parameters proposal
<https://www.reddit.com/r/cpp/comments/5mdes5/what_happened_to_the_named_parameter_proposal/>.
I also believe it is wrong for names which are part of the API to be easily
changeable like that. Additionally, consider name-only parameters. If they
could be renamed, that would be dependent on the order in which they are
declared, which I consider to be an implementation detail. I'm okay if it
is allowed, but I strongly prefer it to be disallowed.


> void foo(int = 1);
>
> void f() {
>   void foo(int = 2);
>   foo();
> }
>

Named parameters are very different from default parameters. I dislike that
we can even do this for default arguments. I'd rather be more restrictive
and find we should loosen the restriction later than be less restrictive
and find we should have tightened the restrictions.

I'm not saying that this is good code, but the truth is that indeed there
> is no way to enforce this requirement over multiple TUs for every single
> case. There is the possibility of making this IF;NDR, but really, I don't
> see why I shouldn't be able to rename parameters (coding/style guidelines?).
>

I believe it is possible to enforce this over multiple TUs in some basic
cases, but thinking about it, I guess it is true that it doesn't work for
some of the more complex cases. If we mangle the names of every named
parameter into the symbol, though, that would catch many cases, I believe,
albeit with a not-very-descriptive diagnostic. IF;NDR is my preference
otherwise.


> Now for templates. In order to have higher-order functions which work on
>> named parameters, I believe it is necessary to have a new kind of template
>> parameter, something like this:
>>
>
> Oh I don't like this; it's too different if you know what I mean. What do
> you think of saying that the named parameter is implicitly part of the
> expansion if the expansion happens in a function parameter list?
>

I thought about this. My primary concern is that functions which were never
designed with named parameters in mind suddenly can be called with named
parameters. I believe it is best to give library authors the chance to
think about this new aspect of the API before opening it up to all named
parameters.

Other things:

   - This would be similar to if Python's varargs accepted kwargs as well.
   I don't like this.
   - How would the library author restrict a function to only named
   parameters, or only positional parameters?
   - There would be quite a bit of work figuring out all the cases where a
   name should be generated and where a name should not be generated. It might
   not even be possible.



> template <typename ...Ts>
> auto f(Ts ...Args) {                             // No change here.
>   g(Args...);                                         // Same.
>   return {Args...}[0];                          // Same.
> }
>
> f(1, 2); // ok: calls g(1, 2); returns 1
> f(.Lhs = 1, .Rhs = 2); // ok; calls g(.Lhs = 1, .Rhs = 2); returns 1
>


> For example, it would be nice to be easily able to specify the allocator
>> of an unordered_map: std::unordered_map<Key, Value, .allocator =
>> MyAllocator> . I believe this would break ABI compatibility, though.
>
>
> How would this break ABI compatibility? The name of the function arguments
> need to to be mangled (which is a non-issue for templates in any case).
>

It depends on how it is implemented. True, it only has to be a reordering,
in which case it would be fully ABI compatible. For some reason, I was
imagining the names being mangled into the type.

-- 
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
To view this discussion on the web visit https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/CAPuuy5d7ZxTzoV%2BFaXrM0zd-QrDwctDWRPO_t002PQgHvwF07A%40mail.gmail.com.

--00000000000049578b057387a1b7
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><br><br><div class=3D"gmail_quote"><div dir=3D"ltr">On Wed=
, Aug 15, 2018 at 10:55 PM Nicolas Lesser &lt;<a href=3D"mailto:blitzrakete=
@gmail.com">blitzrakete@gmail.com</a>&gt; wrote:<br></div><blockquote class=
=3D"gmail_quote" style=3D"margin:0px 0px 0px 0.8ex;border-left:1px solid rg=
b(204,204,204);padding-left:1ex"><div dir=3D"ltr"><blockquote class=3D"gmai=
l_quote" style=3D"margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,20=
4,204);padding-left:1ex">For declaring a function with named parameters, it=
 is imperative that it is opt-in, otherwise, functions parameter names beco=
me part of the public API of the function, which is undesirable</blockquote=
><div dir=3D"auto" style=3D"font-family:sans-serif"><br>Pardon my ignorance=
, but why exactly is this undesirable? Designated initializer lists are als=
o not opt-in. I don&#39;t really see a problem with this. I can&#39;t imagi=
ne function parameters to change once they&#39;re the function is part of t=
he API.</div></div></blockquote><div><br></div><div>Consider all the standa=
rd library functions. Suddenly all the parameter names become public. Here&=
#39;s an example from this reddit thread (<a href=3D"https://www.reddit.com=
/r/cpp/comments/5mdes5/what_happened_to_the_named_parameter_proposal/">http=
s://www.reddit.com/r/cpp/comments/5mdes5/what_happened_to_the_named_paramet=
er_proposal/</a>):</div><div><br></div><div><font face=3D"monospace, monosp=
ace">std::max(._Left =3D 1, ._Right =3D 2)</font></div><div><br></div><div>=
Those names are not intended to be public. They are named strangely like th=
is to avoid problems with user defined macros. We <i>could </i>standardize =
names for every function in the standard, but I believe that is a lot of wo=
rk.</div><div><br></div><div>Also, that would make parameter names part of =
the API by default. I believe library authors would like the opt-in design,=
 as it makes it much easier to make API compatible changes. Names used as f=
unction parameters are not generally expected to be part of the API. Especi=
ally considering that there is a lot of code already written which assumes =
that the parameter names are not part of the API. If we suddenly change it =
to be part of the API, the library authors had no say in whether those name=
s should be part of the API.</div><div>=C2=A0</div><blockquote class=3D"gma=
il_quote" style=3D"margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,2=
04,204);padding-left:1ex"><div dir=3D"ltr"><div></div><blockquote class=3D"=
gmail_quote" style=3D"margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(20=
4,204,204);padding-left:1ex"><div>There should be some way to specify that =
the parameter is name-only. For example, altering=C2=A0<a href=3D"https://w=
ww.python.org/dev/peps/pep-3102/" target=3D"_blank">Python&#39;s implementa=
tion</a>:</div><div><br></div><div><font face=3D"monospace, monospace">// a=
nything after the . is name-only</font></div><div><font face=3D"monospace, =
monospace">int foo(., int .x);</font></div><div><br></div><div>Default argu=
ments should be able to work as they are now.</div></blockquote><div><br></=
div><div>I disagree with your proposed solution. Name-only parameters natur=
ally appear when they are after a varadic (&quot;catch-all&quot;) parameter=
, just like in Python&#39;s implementation.=C2=A0</div></div></blockquote><=
div><br></div><div>Good point. I don&#39;t disagree with this, but I didn&#=
39;t like having to specify the types for the variadic template pack. Note =
that PEP 3102, which=C2=A0I linked to, allows Python to leave off the name =
for the variadic parameter. I was imagining something like that</div><div>=
=C2=A0</div><blockquote class=3D"gmail_quote" style=3D"margin:0px 0px 0px 0=
..8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir=3D"l=
tr"><div></div><div>template &lt;typename ...T&gt;</div><div>void f(T ..., =
int name);</div><div><br></div><div>f(.name =3D 1); // name-only argument</=
div><div><br></div><div>Now you have a small problem: C&#39;s variadic para=
meters are specified in the grammar itself to come last, which can be chang=
ed but would require some restructuring. But I don&#39;t think it&#39;s wor=
th supporting them.=C2=A0</div></div></blockquote><div><br></div><div>I agr=
ee here. If supporting C&#39;s varargs is difficult in this case, I don&#39=
;t consider it a big drawback to disallow them when a function has named pa=
rameters.</div><div>=C2=A0</div><blockquote class=3D"gmail_quote" style=3D"=
margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-lef=
t:1ex"><div dir=3D"ltr"><div></div><blockquote class=3D"gmail_quote" style=
=3D"margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding=
-left:1ex"><div>However, I believe that the name should be part of the func=
tion type and should be mangled into the name for the function. It should n=
ot be allowed for the following two declarations to coexist:</div><div><br>=
</div><div><font face=3D"monospace, monospace">int foo(int .x, int .y);</fo=
nt></div><div><font face=3D"monospace, monospace">int foo(int .a, int .b);<=
/font></div><div><br></div><div>If the name of the parameters are not part =
of the function, then if those declarations are in separate translation uni=
ts, there&#39;s little way to enforce that this should fail to compile / li=
nk.</div></blockquote><div><br></div><div>Any reasons to disallow this? I m=
ean, this is already possible:</div></div></blockquote><div><br></div><div>=
My first reason for doing so was to directly address concerns in <a href=3D=
"https://www.reddit.com/r/cpp/comments/5mdes5/what_happened_to_the_named_pa=
rameter_proposal/">a reddit thread asking about a previous named parameters=
 proposal</a>. I also believe it is wrong for names which are part of the A=
PI to be easily changeable like that. Additionally, consider name-only para=
meters. If they could be renamed, that would be dependent on the order in w=
hich they are declared, which I consider to be an implementation detail. I&=
#39;m okay if it is allowed, but I strongly prefer it to be disallowed.</di=
v><div>=C2=A0</div><blockquote class=3D"gmail_quote" style=3D"margin:0px 0p=
x 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div d=
ir=3D"ltr"><div></div><div>void foo(int =3D 1);</div><div><br></div><div>vo=
id f() {<br>=C2=A0 void foo(int =3D 2);</div><div>=C2=A0 foo();</div><div>}=
</div></div></blockquote><div><br></div><div>Named parameters are very diff=
erent from default parameters. I dislike that we can even do this for defau=
lt arguments. I&#39;d rather be more restrictive and find we should loosen =
the restriction later than be less restrictive and find we should have tigh=
tened the restrictions.</div><div><br></div><blockquote class=3D"gmail_quot=
e" style=3D"margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204)=
;padding-left:1ex"><div dir=3D"ltr"><div></div><div>I&#39;m not saying that=
 this is good code, but the truth is that indeed there is no way to enforce=
 this requirement over multiple TUs for every single case. There is the pos=
sibility of making this IF;NDR, but really, I don&#39;t see why I shouldn&#=
39;t be able to rename parameters (coding/style guidelines?).</div></div></=
blockquote><div><br></div><div>I believe it is possible to enforce this ove=
r multiple TUs in some basic cases, but thinking about it, I guess it is tr=
ue that it doesn&#39;t work for some of the more complex cases. If we mangl=
e the names of every named parameter into the symbol, though, that would ca=
tch many cases, I believe, albeit with a not-very-descriptive diagnostic. I=
F;NDR is my preference otherwise.</div><div>=C2=A0</div><blockquote class=
=3D"gmail_quote" style=3D"margin:0px 0px 0px 0.8ex;border-left:1px solid rg=
b(204,204,204);padding-left:1ex"><div dir=3D"ltr"><blockquote class=3D"gmai=
l_quote" style=3D"margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,20=
4,204);padding-left:1ex">Now for templates. In order to have higher-order f=
unctions which work on named parameters, I believe it is necessary to have =
a new kind of template parameter, something like this:<br></blockquote><div=
><br></div><div>Oh I don&#39;t like this; it&#39;s too different if you kno=
w what I mean. What do you think of saying that the named parameter is impl=
icitly part of the expansion if the expansion happens in a function paramet=
er list?</div></div></blockquote><div><br></div><div>I thought about this. =
My primary concern is that functions which were never designed with named p=
arameters in mind suddenly can be called with named parameters. I believe i=
t is best to give library authors the chance to think about this new aspect=
 of the API before opening it up to all named parameters.</div><div><br></d=
iv><div>Other things:</div><div><ul><li>This would be similar to if Python&=
#39;s varargs accepted kwargs as well. I don&#39;t like this.</li><li>How w=
ould the library author restrict a function to only named parameters, or on=
ly positional parameters?</li><li>There would be quite a bit of work figuri=
ng out all the cases where a name should be generated and where a name shou=
ld not be generated. It might not even be possible.</li></ul></div><div>=C2=
=A0</div><blockquote class=3D"gmail_quote" style=3D"margin:0px 0px 0px 0.8e=
x;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir=3D"ltr"=
><div></div><div>template &lt;typename ...Ts&gt;</div><div>auto f(Ts ...Arg=
s) {=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0// No change here.</div><div>=C2=A0 g(Arg=
s...);=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0=
 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=
=A0// Same.</div><div>=C2=A0 return {Args...}[0];=C2=A0 =C2=A0 =C2=A0 =C2=
=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 // Same.=
</div><div>}</div><div><br></div><div>f(1, 2); // ok: calls g(1, 2); return=
s 1</div><div>f(.Lhs =3D 1, .Rhs =3D 2); // ok; calls g(.Lhs =3D 1, .Rhs =
=3D 2); returns 1</div></div></blockquote><div>=C2=A0</div><blockquote clas=
s=3D"gmail_quote" style=3D"margin:0px 0px 0px 0.8ex;border-left:1px solid r=
gb(204,204,204);padding-left:1ex"><div dir=3D"ltr"><blockquote class=3D"gma=
il_quote" style=3D"margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,2=
04,204);padding-left:1ex">For example, it would be nice to be easily able t=
o specify the allocator of an unordered_map:=C2=A0<font face=3D"monospace, =
monospace">std::unordered_map&lt;Key, Value, .allocator =3D MyAllocator&gt;=
</font><font face=3D"arial, helvetica, sans-serif">=C2=A0. I believe this w=
ould break ABI compatibility, though.</font></blockquote><div><br></div><di=
v>How would this break ABI compatibility? The name of the function argument=
s need to to be mangled (which is a non-issue for templates in any case).=
=C2=A0=C2=A0</div></div></blockquote><div><br></div><div>It depends on how =
it is implemented. True, it only has to be a reordering, in which case it w=
ould be fully ABI compatible. For some reason, I was imagining the names be=
ing mangled into the type.</div><div><br></div></div></div>

<p></p>

-- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals&quot; group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<br />
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/CAPuuy5d7ZxTzoV%2BFaXrM0zd-QrDwctDWRP=
O_t002PQgHvwF07A%40mail.gmail.com?utm_medium=3Demail&utm_source=3Dfooter">h=
ttps://groups.google.com/a/isocpp.org/d/msgid/std-proposals/CAPuuy5d7ZxTzoV=
%2BFaXrM0zd-QrDwctDWRPO_t002PQgHvwF07A%40mail.gmail.com</a>.<br />

--00000000000049578b057387a1b7--

.
