220 11465 <5bae7c28-542c-4d00-ad85-6025bb98e9b8@isocpp.org> article
Path: news.gmane.org!not-for-mail
From: Matthew Fioravante <fmatthew5876@gmail.com>
Newsgroups: gmane.comp.lang.c++.isocpp.proposals
Subject: Re: Named function parameters using anonymous structs
 for C and C++
Date: Mon, 16 Jun 2014 22:18:18 -0700 (PDT)
Lines: 191
Approved: news@gmane.org
Message-ID: <5bae7c28-542c-4d00-ad85-6025bb98e9b8@isocpp.org>
References: <72c49240-547b-4bf6-8b27-aff6a61c1272@isocpp.org> <a36b1035-fabd-402f-9817-498acd56e614@isocpp.org> <29C6D83B-BD31-42A9-B7BD-2C797E3FE58C@gmail.com>
 <26565335.62izyTXvIe@tjmaciei-mobl4>
Reply-To: std-proposals@isocpp.org
NNTP-Posting-Host: plane.gmane.org
Mime-Version: 1.0
Content-Type: multipart/alternative; 
	boundary="----=_Part_1914_15351143.1402982298273"
X-Trace: ger.gmane.org 1402982305 31748 80.91.229.3 (17 Jun 2014 05:18:25 GMT)
X-Complaints-To: usenet@ger.gmane.org
NNTP-Posting-Date: Tue, 17 Jun 2014 05:18:25 +0000 (UTC)
To: std-proposals@isocpp.org
Original-X-From: std-proposals+bncBDELF54RTIGRBGU776OAKGQEKBNMV3I@isocpp.org Tue Jun 17 07:18:20 2014
Return-path: <std-proposals+bncBDELF54RTIGRBGU776OAKGQEKBNMV3I@isocpp.org>
Envelope-to: gclcip-std-proposals@m.gmane.org
Original-Received: from mail-ig0-f199.google.com ([209.85.213.199])
	by plane.gmane.org with esmtp (Exim 4.69)
	(envelope-from <std-proposals+bncBDELF54RTIGRBGU776OAKGQEKBNMV3I@isocpp.org>)
	id 1Wwlmm-0000nm-Bi
	for gclcip-std-proposals@m.gmane.org; Tue, 17 Jun 2014 07:18:20 +0200
Original-Received: by mail-ig0-f199.google.com with SMTP id h18sf14430750igc.10
        for <gclcip-std-proposals@m.gmane.org>; Mon, 16 Jun 2014 22:18:19 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=gmail.com; s=20120113;
        h=date:from:to:message-id:in-reply-to:references:subject:mime-version
         :x-original-sender:reply-to:precedence:mailing-list:list-id
         :list-post:list-help:list-archive:list-subscribe:list-unsubscribe
         :content-type;
        bh=tgOsZhRHmetQwPgzmkVMp3d6KMrTQ2Fmu17WhX5duXk=;
        b=rOa9thlQ5gjGx7RQr4sPVgAZ9tf7myVIVJ4kJSX5ZRTGUKIWlmKqUoHJa8LJE/OH5r
         uY+Z/H+7QHpjyXPUmNSdrMfraIwaF8LU4d95KQr1vFVFDYmBcuMiOxhL4q77HItPhL52
         rrL8o52vYtZpPifRJQ2LiEoMEHdq3Jhic2Upefjj+cONPUfN7CmFXfT2hPZChFkpLofl
         XuG0I3fU3SJFe3Vfz41vGipdQzj5NXbG2yry9tyonGcDMMad5c6PfnQwTp96bQBQ4muJ
         hf2osGHK9Htvb7Ev0C5NXzDEytJwSib1qozEWqm9IDvhSWPn1P0++WlRUP03WkQ1JE3o
         EAyQ==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20130820;
        h=x-gm-message-state:date:from:to:message-id:in-reply-to:references
         :subject:mime-version:x-original-sender:reply-to:precedence
         :mailing-list:list-id:list-post:list-help:list-archive
         :list-subscribe:list-unsubscribe:content-type;
        bh=tgOsZhRHmetQwPgzmkVMp3d6KMrTQ2Fmu17WhX5duXk=;
        b=MDaIWlIDjo6WU3cj596ABWVqHFNwE47OM8FpjTa+TlLIfzp7p9X9ojnzzZ7Y0LuI0u
         heiXcbwLzy1slGQeecO09XHFivDJ+s3zQjUgi6xCPOvQlfCKgoD/WwvCm6ouTgigXlE9
         HhBH1Tac9XuE6M9K2gplVuZUeB9XeLCSjvOLbrhoHGSxdbX9f9oo9A7zJwUT7H2WuUyb
         NO8aDQyvCx4dB3tAU+dtwh7SvSObKVtnO2108ZlEFWhgXRUw9UJ2WSYumKRHyhNqbdyE
         oC8L46p+PtxKPXGTR+krD4mGrmeXzp/qRuI3jqExStqiwaqaMLavr1T+HUi5GKBSz+hq
         +AZw==
X-Gm-Message-State: ALoCoQkfez7HgXH6wYRI1tbaGXDHOQkX/7PAtDwTlSlBlIJ1Eq2xNQlcDGiguQPShca1xFFCc3cq
X-Received: by 10.42.233.133 with SMTP id jy5mr1267059icb.32.1402982299432;
        Mon, 16 Jun 2014 22:18:19 -0700 (PDT)
X-BeenThere: std-proposals@isocpp.org
Original-Received: by 10.140.27.138 with SMTP id 10ls4734840qgx.9.gmail; Mon, 16 Jun
 2014 22:18:18 -0700 (PDT)
X-Received: by 10.140.107.35 with SMTP id g32mr426387qgf.2.1402982298862;
        Mon, 16 Jun 2014 22:18:18 -0700 (PDT)
In-Reply-To: <26565335.62izyTXvIe@tjmaciei-mobl4>
X-Original-Sender: fmatthew5876@gmail.com
Precedence: list
Mailing-list: list std-proposals@isocpp.org; contact std-proposals+owners@isocpp.org
List-ID: <std-proposals.isocpp.org>
X-Google-Group-Id: 399137483710
List-Post: <http://groups.google.com/a/isocpp.org/group/std-proposals/post>, <mailto:std-proposals@isocpp.org>
List-Help: <http://support.google.com/a/isocpp.org/bin/topic.py?topic=25838>, <mailto:std-proposals+help@isocpp.org>
List-Archive: <http://groups.google.com/a/isocpp.org/group/std-proposals/>
List-Subscribe: <http://groups.google.com/a/isocpp.org/group/std-proposals/subscribe>,
 <mailto:std-proposals+subscribe@isocpp.org>
List-Unsubscribe: <http://groups.google.com/a/isocpp.org/group/std-proposals/subscribe>,
 <mailto:googlegroups-manage+399137483710+unsubscribe@googlegroups.com>
Xref: news.gmane.org gmane.comp.lang.c++.isocpp.proposals:11465
Archived-At: <http://permalink.gmane.org/gmane.comp.lang.c++.isocpp.proposals/11465>

------=_Part_1914_15351143.1402982298273
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable



On Tuesday, June 17, 2014 1:10:40 AM UTC-4, Thiago Macieira wrote:
>
> Em ter 17 jun 2014, =C3=A0s 12:43:19, David Krauss escreveu:=20
> > On 2014-06-17, at 10:46 AM, Matthew Fioravante <fmatth...@gmail.com=20
> <javascript:>>=20
> wrote:=20
> > > The original style:=20
> > >=20
> > > int foo(int a, int b, string c);=20
> > > foo(.a =3D 0, .b =3D 1, .c =3D "Hello");=20
> > >=20
> > > Pros:=20
> > > - Very simple=20
> > > - No ABI changes=20
> > > - All legacy code immediately becomes named function enabled=20
> >=20
> > > Cons:=20
> > The big con is that without ABI support, there's no overloading. My=20
> example=20
> > wouldn't work because both rect::rect overloads would mangle to the sam=
e=20
> > name.=20
>
> Use a tag struct as a differentiator:=20
>
>         struct TopLeftBottomRight {};=20
>         rect(int top, int left, int bottom, int right, TopLeftBottomRight=
=20
> =3D {})=20
>         =20
>         struct TopLeftWidthHeight {};=20
>         rect(int top, int left, int width, int height, TopLeftWidthHeight=
=20
> =3D {});=20
>
> That's one way to do it, if we cannot come up with a nice naming rule.

> > - Cannot use named syntax when calling via a function pointer, since=20
> the=20
> > > type has no concept of parameter names. - Requires some language=20
> changes=20
> > > to enable the callsite syntax=20
> > > - Argument names while not part of the ABI, are now part of the API.=
=20
> You=20
> > > cannot change the names or you will break callers.=20
> > This is sort-of inherent to the feature, but it suggests that having=20
> foreign=20
> > (member declaration) syntax for named parameters is actually a good=20
> thing.=20
>
> You can specify parameter names in the function pointer syntax...=20
>

But they are meaningless, and I don't want to try to propose we change the=
=20
type system for function pointers. You might be able to extract the names=
=20
in simple cases, but when it comes to templates, auto, and decltype it=20
could get very messy.

=20

>
> --=20
> Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org=20
>    Software Architect - Intel Open Source Technology Center=20
>       PGP/GPG: 0x6EF45358; fingerprint:=20
>       E067 918B B660 DBD1 105C  966C 33F5 F005 6EF4 5358=20
>
>

--=20

---=20
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 e=
mail to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposa=
ls/.

------=_Part_1914_15351143.1402982298273
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><br><br>On Tuesday, June 17, 2014 1:10:40 AM UTC-4, Thiago=
 Macieira wrote:<blockquote class=3D"gmail_quote" style=3D"margin: 0;margin=
-left: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;">Em ter 17 jun =
2014, =C3=A0s 12:43:19, David Krauss escreveu:
<br>&gt; On 2014-06-17, at 10:46 AM, Matthew Fioravante &lt;<a href=3D"java=
script:" target=3D"_blank" gdf-obfuscated-mailto=3D"R7SyU1e7rD8J" onmousedo=
wn=3D"this.href=3D'javascript:';return true;" onclick=3D"this.href=3D'javas=
cript:';return true;">fmatth...@gmail.com</a>&gt;=20
<br>wrote:
<br>&gt; &gt; The original style:
<br>&gt; &gt;=20
<br>&gt; &gt; int foo(int a, int b, string c);
<br>&gt; &gt; foo(.a =3D 0, .b =3D 1, .c =3D "Hello");
<br>&gt; &gt;=20
<br>&gt; &gt; Pros:
<br>&gt; &gt; - Very simple
<br>&gt; &gt; - No ABI changes
<br>&gt; &gt; - All legacy code immediately becomes named function enabled
<br>&gt;=20
<br>&gt; &gt; Cons:
<br>&gt; The big con is that without ABI support, there's no overloading. M=
y example
<br>&gt; wouldn't work because both rect::rect overloads would mangle to th=
e same
<br>&gt; name.
<br>
<br>Use a tag struct as a differentiator:
<br>
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;struct TopLeftBottomRig=
ht {};
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;rect(int top, int left,=
 int bottom, int right, TopLeftBottomRight =3D {})
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;struct TopLeftWidthHeig=
ht {};
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;rect(int top, int left,=
 int width, int height, TopLeftWidthHeight =3D {});
<br>
<br></blockquote><div>That's one way to do it, if we cannot come up with a =
nice naming rule.</div><div><br></div><blockquote class=3D"gmail_quote" sty=
le=3D"margin: 0;margin-left: 0.8ex;border-left: 1px #ccc solid;padding-left=
: 1ex;">&gt; &gt; - Cannot use named syntax when calling via a function poi=
nter, since the
<br>&gt; &gt; type has no concept of parameter names. - Requires some langu=
age changes
<br>&gt; &gt; to enable the callsite syntax
<br>&gt; &gt; - Argument names while not part of the ABI, are now part of t=
he API. You
<br>&gt; &gt; cannot change the names or you will break callers.
<br>&gt; This is sort-of inherent to the feature, but it suggests that havi=
ng foreign
<br>&gt; (member declaration) syntax for named parameters is actually a goo=
d thing.
<br>
<br>You can specify parameter names in the function pointer syntax...
<br></blockquote><div><br></div><div>But they are meaningless, and I don't =
want to try to propose we change the type system for function pointers. You=
 might be able to extract the names in simple cases, but when it comes to t=
emplates, auto, and decltype it could get very messy.</div><div><br></div><=
div>&nbsp;</div><blockquote class=3D"gmail_quote" style=3D"margin: 0;margin=
-left: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;">
<br>--=20
<br>Thiago Macieira - thiago (AT) <a href=3D"http://macieira.info" target=
=3D"_blank" onmousedown=3D"this.href=3D'http://www.google.com/url?q\75http%=
3A%2F%2Fmacieira.info\46sa\75D\46sntz\0751\46usg\75AFQjCNEswDUBNCNanbu7euhq=
Ln_62FW8ag';return true;" onclick=3D"this.href=3D'http://www.google.com/url=
?q\75http%3A%2F%2Fmacieira.info\46sa\75D\46sntz\0751\46usg\75AFQjCNEswDUBNC=
Nanbu7euhqLn_62FW8ag';return true;">macieira.info</a> - thiago (AT) <a href=
=3D"http://kde.org" target=3D"_blank" onmousedown=3D"this.href=3D'http://ww=
w.google.com/url?q\75http%3A%2F%2Fkde.org\46sa\75D\46sntz\0751\46usg\75AFQj=
CNHGRJdo5_JYG1DowztwAHAKs80XSA';return true;" onclick=3D"this.href=3D'http:=
//www.google.com/url?q\75http%3A%2F%2Fkde.org\46sa\75D\46sntz\0751\46usg\75=
AFQjCNHGRJdo5_JYG1DowztwAHAKs80XSA';return true;">kde.org</a>
<br>&nbsp; &nbsp;Software Architect - Intel Open Source Technology Center
<br>&nbsp; &nbsp; &nbsp; PGP/GPG: 0x6EF45358; fingerprint:
<br>&nbsp; &nbsp; &nbsp; E067 918B B660 DBD1 105C &nbsp;966C 33F5 F005 6EF4=
 5358
<br>
<br></blockquote></div>

<p></p>

-- <br />
<br />
--- <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 />
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/">http://groups.google.com/a/isocpp.org/group/std-proposals/<=
/a>.<br />

------=_Part_1914_15351143.1402982298273--

.
