220 28791 <cb3a913d-7227-49fa-af5a-03b89690f822@isocpp.org> article
Path: news.gmane.org!.POSTED!not-for-mail
From: TONGARI J <tongari95@gmail.com>
Newsgroups: gmane.comp.lang.c++.isocpp.proposals
Subject: Re: Ideas for extending std::tuple with field-name
 based access
Date: Thu, 13 Oct 2016 05:21:31 -0700 (PDT)
Lines: 169
Approved: news@gmane.org
Message-ID: <cb3a913d-7227-49fa-af5a-03b89690f822@isocpp.org>
References: <CANu6V4VcQQxjb0LvEVjAeNkZ892Gn32cirgVwfjYuAJkkR5EPA@mail.gmail.com>
 <1eec31c2-4e39-4318-861c-eb917b75cbe8@isocpp.org>
 <5eeef837-6e0f-4544-b610-0474c6aaa02a@isocpp.org>
 <903009b9-8585-406d-9c12-d0e437e62f10@isocpp.org>
 <4ff0672d-9cb5-41d9-a990-3ea95fee1014@isocpp.org>
 <330ab8be-0fce-4e55-8e34-925a81fc61be@isocpp.org>
Reply-To: std-proposals@isocpp.org
NNTP-Posting-Host: blaine.gmane.org
Mime-Version: 1.0
Content-Type: multipart/mixed; 
	boundary="----=_Part_735_24122487.1476361291234"
X-Trace: blaine.gmane.org 1476361318 14293 195.159.176.226 (13 Oct 2016 12:21:58 GMT)
X-Complaints-To: usenet@blaine.gmane.org
NNTP-Posting-Date: Thu, 13 Oct 2016 12:21:58 +0000 (UTC)
To: ISO C++ Standard - Future Proposals <std-proposals@isocpp.org>
Original-X-From: std-proposals+bncBCC3NA775MLBBTHY7W7QKGQE3V57ZOA@isocpp.org Thu Oct 13 14:21:53 2016
Return-path: <std-proposals+bncBCC3NA775MLBBTHY7W7QKGQE3V57ZOA@isocpp.org>
Envelope-to: gclcip-std-proposals@m.gmane.org
Original-Received: from mail-it0-f70.google.com ([209.85.214.70])
	by blaine.gmane.org with esmtp (Exim 4.84_2)
	(envelope-from <std-proposals+bncBCC3NA775MLBBTHY7W7QKGQE3V57ZOA@isocpp.org>)
	id 1buf0v-0000fd-EQ
	for gclcip-std-proposals@m.gmane.org; Thu, 13 Oct 2016 14:21:33 +0200
Original-Received: by mail-it0-f70.google.com with SMTP id q75sf107150932itc.6
        for <gclcip-std-proposals@m.gmane.org>; Thu, 13 Oct 2016 05:21:35 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=isocpp-org.20150623.gappssmtp.com; s=20150623;
        h=date:from:to:message-id:in-reply-to:references:subject:mime-version
         :x-original-sender:reply-to:precedence:mailing-list:list-id
         :x-spam-checked-in-group:list-post:list-help:list-archive
         :list-subscribe:list-unsubscribe;
        bh=ykRvjrmdOipBYLJr8O6fsQqnAiZzjT+RiIOHoEwXIi8=;
        b=tFcaTJHF9PvkPPJ6Hdvz/QRa03pqwSJnaBJko0tyOBiQPJQEoIW3kgoPHTK3Vpg2Gv
         ntWeqaIv7bve40MrfZ5pxhtLAlx1WARa9TLV9ja1cVeYSFdtWY5GA/ZyY91n7ho1C08X
         LhFvMs3IDymd19cKyfDwjIFpIeJDQWPzwtWdhoBWoTzJObQ+6IevWmexrg+weqWs95j2
         KecZhUCi1BJLgdwp0I+sPTch+dZihjibeQAIKW4kmI6l6thTkBSNdi6V7ouz0rpq05mS
         Jyee9j8fRNP/noE110ybIvIKRI0NHrxOcNm0bKk//S6KRT9iE7j/2nVm6+457f35qd1U
         uQ4Q==
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
         :x-spam-checked-in-group:list-post:list-help:list-archive
         :list-subscribe:list-unsubscribe;
        bh=ykRvjrmdOipBYLJr8O6fsQqnAiZzjT+RiIOHoEwXIi8=;
        b=uOYJYoFSKPG25P0RO1Z6Ckjo5BSFJ25REBq1gHeVbv1GIBqpYYKI2dpHsvn0oIM9Nc
         InMcwXE09CXTKBmh62C3KeJ+5+jvX5VlUul3d1t/KG2BMjSuIwkQQDLQXTlrkEG10FAr
         HSeQlXofg5GNHpBxOwOrVBtKbaKZHM6Y+MMq7P+G5pShVum51QU6ZBo+NRrp7xr0f/63
         o+SHa3siM2ZD3CH/0ulEfwHQZJn0zlsCT3Jz+2GQfjgfiVnukz4b9cEFuuSI2sxFCEgg
         j9kMvZhXGQPTpXOZjAozp5b/JFv/AM6ivssPbnPbpk5gyHCtivIFnJO6DNh4sN6Zavz8
         Z/hw==
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:x-spam-checked-in-group:list-post:list-help
         :list-archive:list-subscribe:list-unsubscribe;
        bh=ykRvjrmdOipBYLJr8O6fsQqnAiZzjT+RiIOHoEwXIi8=;
        b=Ja8biF+XHqMLncr9UjpDsFzl119GkTQyc3ZDvtrwGQsrcPhJamW7CJcL+KKghk+3GV
         4nrbOGDkXcLA7jp2KclYd63NUAKoQXS6LD1FuhNvWxPx+DcskDMNtcVi7r6qqkzZYOuA
         +JkrxGgqskHT+YNVfCoTWFPCW6fzCbeWa5fYANNbbYkYnnep/MvvbspZwLecAfVuabSD
         NQFlBDd3nQ1mo9fc5MzAAhHsd9GyH2WkNW6MXQH8nhcFu09eIn9TYv509XFTexiVoUqB
         SbvveCoSjIYooBVM9GWRIfx/4kRpdJbK9S0Lp57Mga9As4E81wNcdNafHLtvov29cvW/
         u8kQ==
X-Gm-Message-State: AA6/9RkWWXUOFnbAGG3iszYO/5lzoqQw59Stln5+CldWiv6fEo9UXcKK2eD3r4pfc/SgSw==
X-Received: by 10.36.227.205 with SMTP id d196mr2125566ith.14.1476361295402;
        Thu, 13 Oct 2016 05:21:35 -0700 (PDT)
X-BeenThere: std-proposals@isocpp.org
Original-Received: by 10.36.230.3 with SMTP id e3ls2413197ith.7.gmail; Thu, 13 Oct 2016
 05:21:32 -0700 (PDT)
X-Received: by 10.36.77.75 with SMTP id l72mr485537itb.1.1476361292580;
        Thu, 13 Oct 2016 05:21:32 -0700 (PDT)
In-Reply-To: <330ab8be-0fce-4e55-8e34-925a81fc61be@isocpp.org>
X-Original-Sender: tongari95@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: <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:28791
Archived-At: <http://permalink.gmane.org/gmane.comp.lang.c++.isocpp.proposals/28791>

------=_Part_735_24122487.1476361291234
Content-Type: multipart/alternative; 
	boundary="----=_Part_736_1115471485.1476361291234"

------=_Part_736_1115471485.1476361291234
Content-Type: text/plain; charset=UTF-8

On Thursday, October 13, 2016 at 6:50:30 PM UTC+8, Giovanni Piero Deretta 
wrote:
>
> On Thursday, October 13, 2016 at 11:04:47 AM UTC+1, TONGARI J wrote:
>>
>> On Thursday, October 13, 2016 at 5:55:41 PM UTC+8, Giovanni Piero Deretta 
>> wrote:
>>>
>>> On Thursday, October 13, 2016 at 10:50:41 AM UTC+1, TONGARI J wrote:
>>>>
>>>>
>>>> With my experimental language features + template arg deduction from 
>>>> ctor (C++17), this is possible:
>>>> std::tuple tup(.foo = 10, .bar = 20); // deduced to 
>>>> std::tuple<int.foo, int.bar>
>>>> assert(tuple.foo == 10);
>>>> assert(tuple.bar == 20);
>>>>
>>>>
>>> So it seems! That's exactly my end game. 
>>> Do you already have some draft proposal? I have been focusing on the 
>>> emulation implementation.
>>>
>>
>> They're some extensions to my last uniform designator idea that I posted 
>> months ago.
>> So no draft proposal yet, I only have a working implementation based on 
>> Clang (still some ABI issues to solve).
>>
>
> I had completely forgotten about that proposal (even though I had 
> commented on it saying I liked it!). I ended up reinventing the idea, (even 
> the . based opt-in for named parameters); possibly I was influenced 
> subconsciously :).
>
> In my design,  an '.<identifier>' expression by itself is a literal for 
> some std::identifier<I> (where I is unspecified and there is 1:1 mapping 
> from I to 'identifier'). std::identifier would overload operator=(T) to 
> return an std::assignment_expression<I, T>. 
> std::as_field(std::assignment_expression<I,T>) returns an unspecified 
> structure with a single field named 'identifier; of type T. Similarly, 
> std::identifier<I>::operator(T x, Rest... rest) would return the result of 
> the first valid of these: x.<identifier>, x.<identifier>(rest...), 
> <identifier>(x, rest...), does_not_understand(std::identifier<I>, x, rest); 
> constexpr identifier<I>::name() would return a string_view over 
> "<identifier>".
>
> These can all be implemented in C++14 (with the help of the preprocessor), 
> and by themselves already allow for a lot of functionality.
>

It's quite cool as a macro approach.

The unspecified `I` in your idea maps directly to the "template declname 
parameter" in my design.

In my design (so is in C99), '.<identifier> = <expr>' is not a real 
expression, and '.<identifier>' itself does not form an expression as well.
While you can still implement the `identifier<I>` as you described, but I 
think it becomes unnecessary.

The ability to retrieve the name string is worth considering, could be a 
variable template that connects to some compiler intrinsic.

-- 
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/cb3a913d-7227-49fa-af5a-03b89690f822%40isocpp.org.

------=_Part_736_1115471485.1476361291234
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr">On Thursday, October 13, 2016 at 6:50:30 PM UTC+8, Giovann=
i Piero Deretta wrote:<blockquote class=3D"gmail_quote" style=3D"margin: 0;=
margin-left: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;"><div dir=
=3D"ltr">On Thursday, October 13, 2016 at 11:04:47 AM UTC+1, TONGARI J wrot=
e:<blockquote class=3D"gmail_quote" style=3D"margin:0;margin-left:0.8ex;bor=
der-left:1px #ccc solid;padding-left:1ex"><div dir=3D"ltr">On Thursday, Oct=
ober 13, 2016 at 5:55:41 PM UTC+8, Giovanni Piero Deretta wrote:<blockquote=
 class=3D"gmail_quote" style=3D"margin:0;margin-left:0.8ex;border-left:1px =
#ccc solid;padding-left:1ex"><div dir=3D"ltr">On Thursday, October 13, 2016=
 at 10:50:41 AM UTC+1, TONGARI J wrote:<blockquote class=3D"gmail_quote" st=
yle=3D"margin:0;margin-left:0.8ex;border-left:1px #ccc solid;padding-left:1=
ex"><div dir=3D"ltr"><br><div>With my experimental language features + temp=
late arg deduction from ctor (C++17), this is possible:</div><div><div styl=
e=3D"background-color:rgb(250,250,250);border-color:rgb(187,187,187);border=
-style:solid;border-width:1px;word-wrap:break-word"><code><div><span style=
=3D"color:#000">std</span><span style=3D"color:#660">::</span><span style=
=3D"color:#000">tuple tup</span><span style=3D"color:#660">(.</span><span s=
tyle=3D"color:#000">foo </span><span style=3D"color:#660">=3D</span><span s=
tyle=3D"color:#000"> </span><span style=3D"color:#066">10</span><span style=
=3D"color:#660">,</span><span style=3D"color:#000"> </span><span style=3D"c=
olor:#660">.</span><span style=3D"color:#000">bar </span><span style=3D"col=
or:#660">=3D</span><span style=3D"color:#000"> </span><span style=3D"color:=
#066">20</span><span style=3D"color:#660">);</span><span style=3D"color:#00=
0"> </span><span style=3D"color:#800">// deduced to std::tuple&lt;int.foo, =
int.bar&gt;</span><span style=3D"color:#000"><br></span><span style=3D"colo=
r:#008">assert</span><span style=3D"color:#660">(</span><span style=3D"colo=
r:#000">tuple</span><span style=3D"color:#660">.</span><span style=3D"color=
:#000">foo </span><span style=3D"color:#660">=3D=3D</span><span style=3D"co=
lor:#000"> </span><span style=3D"color:#066">10</span><span style=3D"color:=
#660">);</span><span style=3D"color:#000"><br></span><span style=3D"color:#=
008">assert</span><span style=3D"color:#660">(</span><span style=3D"color:#=
000">tuple</span><span style=3D"color:#660">.</span><span style=3D"color:#0=
00">bar </span><span style=3D"color:#660">=3D=3D</span><span style=3D"color=
:#000"> </span><span style=3D"color:#066">20</span><span style=3D"color:#66=
0">);</span></div></code></div><br></div></div></blockquote><div><br>So it =
seems! That&#39;s exactly my end game. <br>Do you already have some draft p=
roposal? I have been focusing on the emulation implementation.<br></div></d=
iv></blockquote><div><br></div><div>They&#39;re some extensions to my last =
uniform designator idea that I posted months ago.</div><div>So no draft pro=
posal yet, I only have a working implementation based on Clang (still some =
ABI issues to solve).</div></div></blockquote><div><br>I had completely for=
gotten about that proposal (even though I had commented on it saying I like=
d it!). I ended up reinventing the idea, (even the . based opt-in for named=
 parameters); possibly I was influenced subconsciously :).<br><br>In my des=
ign,=C2=A0 an &#39;.&lt;identifier&gt;&#39; expression by itself is a liter=
al for some std::identifier&lt;I&gt; (where I is unspecified and there is 1=
:1 mapping from I to &#39;identifier&#39;). std::identifier would overload =
operator=3D(T) to return an std::assignment_expression&lt;I, T&gt;. std::as=
_field(std::assignment_<wbr>expression&lt;I,T&gt;) returns an unspecified s=
tructure with a single field named &#39;identifier; of type T. Similarly, s=
td::identifier&lt;I&gt;::operator(T x, Rest... rest) would return the resul=
t of the first valid of these: x.&lt;identifier&gt;, x.&lt;identifier&gt;(r=
est...), &lt;identifier&gt;(x, rest...), does_not_understand(std::<wbr>iden=
tifier&lt;I&gt;, x, rest); constexpr identifier&lt;I&gt;::name() would retu=
rn a string_view over &quot;&lt;identifier&gt;&quot;.<br><br>These can all =
be implemented in C++14 (with the help of the preprocessor), and by themsel=
ves already allow for a lot of functionality.<br></div></div></blockquote><=
div><br></div><div>It&#39;s quite cool as a macro approach.</div><div><br><=
/div><div>The unspecified `I` in your idea maps directly to the &quot;templ=
ate declname parameter&quot; in my design.</div><div><br></div><div>In my d=
esign (so is in C99), &#39;.&lt;identifier&gt; =3D &lt;expr&gt;&#39; is not=
 a real expression, and &#39;.&lt;identifier&gt;&#39; itself does not form =
an expression as well.</div><div>While you can still implement the `identif=
ier&lt;I&gt;` as you described, but I think it becomes unnecessary.</div><d=
iv><br></div><div>The ability to retrieve the name string is worth consider=
ing, could be a variable template that connects to some compiler intrinsic.=
</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/cb3a913d-7227-49fa-af5a-03b89690f822%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/cb3a913d-7227-49fa-af5a-03b89690f822=
%40isocpp.org</a>.<br />

------=_Part_736_1115471485.1476361291234--

------=_Part_735_24122487.1476361291234--

.
