220 18237 <62FE5462-BE3F-4C9E-B03D-322CB0CFF753@gmail.com> article
Path: news.gmane.org!not-for-mail
From: Miro Knejp <miro.knejp@gmail.com>
Newsgroups: gmane.comp.lang.c++.isocpp.proposals
Subject: Re: Re: Core Language feature: Multiple assignments
 from multiple return values via tuple
Date: Wed, 27 May 2015 10:51:50 +0200
Lines: 218
Approved: news@gmane.org
Message-ID: <62FE5462-BE3F-4C9E-B03D-322CB0CFF753@gmail.com>
References: <69a59613-6504-466a-9878-786653d6087f@isocpp.org> <4498da2a-af3a-457d-9bf7-e8bb3721d6b9@isocpp.org> <mk2dns$s02$1@ger.gmane.org> <6ea4a1dc-bfb4-4219-93ea-606619a77c53@isocpp.org> <mk2g93$6j5$1@ger.gmane.org> <71a799fc-1897-4c43-adc6-5d26267688bb@isocpp.org> <e41cd575-e64e-4d96-821f-5c6237371ac3@isocpp.org> <500d24fe-73ba-439a-ac53-aeaa7919111e@isocpp.org> <32801228-1faf-4b73-8da1-9c8ce5bcb9ae@isocpp.org> <0b91248a-1994-4127-932e-9e1d97edadb2@isocpp.org> <ae452ecd-fcf2-49c5-8df8-e15687ebbbe0@isocpp.org>
Reply-To: std-proposals@isocpp.org
NNTP-Posting-Host: plane.gmane.org
Mime-Version: 1.0 (Mac OS X Mail 8.2 \(2098\))
Content-Type: multipart/alternative; boundary="Apple-Mail=_3DF0C2DE-72E6-476C-99F6-D723A7EC6453"
X-Trace: ger.gmane.org 1432716731 6512 80.91.229.3 (27 May 2015 08:52:11 GMT)
X-Complaints-To: usenet@ger.gmane.org
NNTP-Posting-Date: Wed, 27 May 2015 08:52:11 +0000 (UTC)
To: std-proposals@isocpp.org
Original-X-From: std-proposals+bncBC6ONSXJ54LBBLMLS2VQKGQEBJSSQOY@isocpp.org Wed May 27 10:52:04 2015
Return-path: <std-proposals+bncBC6ONSXJ54LBBLMLS2VQKGQEBJSSQOY@isocpp.org>
Envelope-to: gclcip-std-proposals@m.gmane.org
Original-Received: from mail-la0-f71.google.com ([209.85.215.71])
	by plane.gmane.org with esmtp (Exim 4.69)
	(envelope-from <std-proposals+bncBC6ONSXJ54LBBLMLS2VQKGQEBJSSQOY@isocpp.org>)
	id 1YxX4C-00006Y-6D
	for gclcip-std-proposals@m.gmane.org; Wed, 27 May 2015 10:52:00 +0200
Original-Received: by lagv1 with SMTP id v1sf1013789lag.1
        for <gclcip-std-proposals@m.gmane.org>; Wed, 27 May 2015 01:51:58 -0700 (PDT)
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20130820;
        h=x-gm-message-state:from:content-type:message-id:mime-version
         :subject:date:references:to:in-reply-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=UQUmUPmJof0GDvMuwZ2Ed0zrK77ZqL2On57RU9LRC+g=;
        b=MwQmEoVPRzolJFuk4OpVYn0cImbsnjfrOa/HChgAB+huZ7GTfyF98QjSKCJAKpug07
         507Kq8oCEYUlmG8bomexPgP8+cFMxGiJ/KHaDYVGyG9xAvI2FZIP1Mh5t2fXuOjLQQ9H
         LCSQjl5rXMtPWR/X23q0oziXabFn/SbI9ZoCNeP75mRKG7yTxpOGVqGONlZYs+TUuxYR
         DpPj7hWsaZecHKx/vsVpbYDddaZGyLRY/VeOJKYj44E1cmKluEz6BAi+0fpWjeqtL5mP
         tolo1FcXVseaLzVjMpmY+0mnYsM3+GW4b7pl5+u22DUgTTZ+xjnThvrq+N4f+fk5WhcN
         c86w==
X-Gm-Message-State: ALoCoQliEM+LD2FHrGbpWH8BktdKYOREmDVxot1gdo95XvPGiL3eRf3q1EOpgXF41C5aiXsD5Cpk
X-Received: by 10.112.151.146 with SMTP id uq18mr31365587lbb.20.1432716718214;
        Wed, 27 May 2015 01:51:58 -0700 (PDT)
X-BeenThere: std-proposals@isocpp.org
Original-Received: by 10.180.76.132 with SMTP id k4ls823396wiw.25.canary; Wed, 27 May
 2015 01:51:56 -0700 (PDT)
X-Received: by 10.181.6.37 with SMTP id cr5mr48515605wid.18.1432716716712;
        Wed, 27 May 2015 01:51:56 -0700 (PDT)
Original-Received: from mail-wg0-x22e.google.com (mail-wg0-x22e.google.com. [2a00:1450:400c:c00::22e])
        by mx.google.com with ESMTPS id s5si28403315wjz.147.2015.05.27.01.51.56
        for <std-proposals@isocpp.org>
        (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128);
        Wed, 27 May 2015 01:51:56 -0700 (PDT)
Received-SPF: pass (google.com: domain of miro.knejp@gmail.com designates 2a00:1450:400c:c00::22e as permitted sender) client-ip=2a00:1450:400c:c00::22e;
Original-Received: by wgme6 with SMTP id e6so3229688wgm.2
        for <std-proposals@isocpp.org>; Wed, 27 May 2015 01:51:56 -0700 (PDT)
X-Received: by 10.180.96.196 with SMTP id du4mr19940642wib.77.1432716712956;
        Wed, 27 May 2015 01:51:52 -0700 (PDT)
Original-Received: from [172.16.1.100] (vpn.qmob.de. [80.147.156.178])
        by mx.google.com with ESMTPSA id w11sm25205521wjr.48.2015.05.27.01.51.51
        for <std-proposals@isocpp.org>
        (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128);
        Wed, 27 May 2015 01:51:52 -0700 (PDT)
In-Reply-To: <ae452ecd-fcf2-49c5-8df8-e15687ebbbe0@isocpp.org>
X-Mailer: Apple Mail (2.2098)
X-Original-Sender: miro.knejp@gmail.com
X-Original-Authentication-Results: mx.google.com;       spf=pass (google.com:
 domain of miro.knejp@gmail.com designates 2a00:1450:400c:c00::22e as
 permitted sender) smtp.mail=miro.knejp@gmail.com;       dkim=pass
 header.i=@gmail.com;       dmarc=pass (p=NONE 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-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: <mailto:googlegroups-manage+399137483710+unsubscribe@googlegroups.com>,
 <http://groups.google.com/a/isocpp.org/group/std-proposals/subscribe>
Xref: news.gmane.org gmane.comp.lang.c++.isocpp.proposals:18237
Archived-At: <http://permalink.gmane.org/gmane.comp.lang.c++.isocpp.proposals/18237>

--Apple-Mail=_3DF0C2DE-72E6-476C-99F6-D723A7EC6453
Content-Transfer-Encoding: quoted-printable
Content-Type: text/plain; charset=UTF-8


> On 27 May 2015, at 09:43 , Nicol Bolas <jmckesson@gmail.com> wrote:
>=20
>=20
> [int,long,double] foo();
> auto x =3D foo();
>=20
> Ok, if tuple is out then what is decltype(x) in the above example doing t=
hings your way?
>=20
> There are two defensible answers to this:
>=20
> 1) A compilation error. You called a function that returns 3 things, but =
you only captured one. That suggests you weren't paying attention.
>=20
> 2) `int`. The other two types are dropped on the floor.
>=20
> #2 is probably the way to go. Any sort of aggregate object type is not ev=
en up for discussion.
>=20
> Multiple return values means multiple return values, not "pack multiple v=
alues into some kind of object and unpack them later".
> =20
> Another kind of typelist which is standard layout compatible? Or are we n=
o longer able to capture all of the return values into one object?
>=20
> If you want to capture them all in an object, you just ask for it:
>=20
> auto x =3D make_tuple(foo());
>=20
> That is neither hard nor particularly verbose. You can even stick them in=
 an array, if all of the returned values are of the same type:
>=20
> auto x =3D make_array(foo());
>=20
> Or in an arbitrary data structure:
>=20
> auto x =3D std::vector<Type>{foo()};
>=20
> But most people using multiple return values don't capture them in a big =
object, so we don't make the syntax optimal for that case.
>=20


I assume Matthew=E2=80=99s point comes from dealing with template code.

template<class F>
??? contrived_example(F f) {
    return f();
}

The author would probably expect that ??? can be plain =E2=80=9Cauto=E2=80=
=9D, implying =E2=80=9Cin some places auto can expand to multiple types=E2=
=80=9D. Then there=E2=80=99s the point of what generic code would require t=
o do to consistently capture the return value(s) of a Callable without know=
ing if there are one or multiple return values.

template<class F>
void contrived_example2(F f) {
    ??? x =3D f();
    ...
}

Should ??? be something that can potentially capture a single or multiple v=
alues depending on the initialization? If so what can be done with x down t=
he pipeline? Or is a concept necessary to overload contrived_example2 for f=
unctions with single or multiple return values? Is template code forced int=
o packing every Callable=E2=80=99s invocation into make_tuple() just in cas=
e it might return multiple values?

--=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/.

--Apple-Mail=_3DF0C2DE-72E6-476C-99F6-D723A7EC6453
Content-Transfer-Encoding: quoted-printable
Content-Type: text/html; charset=UTF-8

<html><head><meta http-equiv=3D"Content-Type" content=3D"text/html charset=
=3Dutf-8"></head><body style=3D"word-wrap: break-word; -webkit-nbsp-mode: s=
pace; -webkit-line-break: after-white-space;" class=3D""><br class=3D""><di=
v><blockquote type=3D"cite" class=3D""><div class=3D"">On 27 May 2015, at 0=
9:43 , Nicol Bolas &lt;<a href=3D"mailto:jmckesson@gmail.com" class=3D"">jm=
ckesson@gmail.com</a>&gt; wrote:</div><br class=3D"Apple-interchange-newlin=
e"><div class=3D""><div dir=3D"ltr" style=3D"font-family: Helvetica; font-s=
ize: 12px; font-style: normal; font-variant: normal; font-weight: normal; l=
etter-spacing: normal; line-height: normal; orphans: auto; text-align: star=
t; text-indent: 0px; text-transform: none; white-space: normal; widows: aut=
o; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=3D""><blockquo=
te class=3D"gmail_quote" style=3D"margin: 0px 0px 0px 0.8ex; border-left-wi=
dth: 1px; border-left-color: rgb(204, 204, 204); border-left-style: solid; =
padding-left: 1ex;"><div dir=3D"ltr" class=3D""><div class=3D""><br class=
=3D""></div><div class=3D""><div style=3D"border: 1px solid rgb(187, 187, 1=
87); word-wrap: break-word; background-color: rgb(250, 250, 250);" class=3D=
""><code class=3D""><span style=3D"color: rgb(102, 102, 0);" class=3D"">[</=
span><span style=3D"color: rgb(0, 0, 136);" class=3D"">int</span><span styl=
e=3D"color: rgb(102, 102, 0);" class=3D"">,</span><span style=3D"color: rgb=
(0, 0, 136);" class=3D"">long</span><span style=3D"color: rgb(102, 102, 0);=
" class=3D"">,</span><span style=3D"color: rgb(0, 0, 136);" class=3D"">doub=
le</span><span style=3D"color: rgb(102, 102, 0);" class=3D"">]</span><span =
class=3D"Apple-converted-space">&nbsp;</span>foo<span style=3D"color: rgb(1=
02, 102, 0);" class=3D"">();</span><br class=3D""><span style=3D"color: rgb=
(0, 0, 136);" class=3D"">auto</span><span style=3D"" class=3D""><span class=
=3D"Apple-converted-space">&nbsp;</span>x<span class=3D"Apple-converted-spa=
ce">&nbsp;</span></span><span style=3D"color: rgb(102, 102, 0);" class=3D""=
>=3D</span><span class=3D"Apple-converted-space">&nbsp;</span>foo<span styl=
e=3D"color: rgb(102, 102, 0);" class=3D"">();</span><font color=3D"#666600"=
 class=3D""></font></code></div><br class=3D""></div><div class=3D"">Ok, if=
 tuple is out then what is decltype(x) in the above example doing things yo=
ur way?</div></div></blockquote><div class=3D""><br class=3D"">There are tw=
o defensible answers to this:<br class=3D""><br class=3D"">1) A compilation=
 error. You called a function that returns 3 things, but you only captured =
one. That suggests you weren't paying attention.<br class=3D""><br class=3D=
"">2) `int`. The other two types are dropped on the floor.<br class=3D""><b=
r class=3D"">#2 is probably the way to go. Any sort of aggregate object typ=
e is not even up for discussion.<br class=3D""><br class=3D"">Multiple retu=
rn values means<span class=3D"Apple-converted-space">&nbsp;</span><i class=
=3D"">multiple return values</i>, not "pack multiple values into some kind =
of object and unpack them later".<br class=3D"">&nbsp;</div><blockquote cla=
ss=3D"gmail_quote" style=3D"margin: 0px 0px 0px 0.8ex; border-left-width: 1=
px; border-left-color: rgb(204, 204, 204); border-left-style: solid; paddin=
g-left: 1ex;"><div dir=3D"ltr" class=3D""><div class=3D"">Another kind of t=
ypelist which is standard layout compatible? Or are we no longer able to ca=
pture all of the return values into one object?</div></div></blockquote><di=
v class=3D""><br class=3D"">If you want to capture them all in an object, y=
ou just ask for it:<br class=3D""><br class=3D""><div class=3D"prettyprint"=
 style=3D"background-color: rgb(250, 250, 250); border: 1px solid rgb(187, =
187, 187); word-wrap: break-word;"><code class=3D"prettyprint"><span class=
=3D"styled-by-prettify" style=3D"color: rgb(0, 0, 136);">auto</span><span c=
lass=3D"styled-by-prettify" style=3D""><span class=3D"Apple-converted-space=
">&nbsp;</span>x<span class=3D"Apple-converted-space">&nbsp;</span></span><=
span class=3D"styled-by-prettify" style=3D"color: rgb(102, 102, 0);">=3D</s=
pan><span class=3D"Apple-converted-space">&nbsp;</span>make_tuple<span clas=
s=3D"styled-by-prettify" style=3D"color: rgb(102, 102, 0);">(</span>foo<spa=
n class=3D"styled-by-prettify" style=3D"color: rgb(102, 102, 0);">());</spa=
n></code></div><br class=3D"">That is neither hard nor particularly verbose=
.. You can even stick them in an array, if all of the returned values are of=
 the same type:<br class=3D""><br class=3D""><div class=3D"prettyprint" sty=
le=3D"background-color: rgb(250, 250, 250); border: 1px solid rgb(187, 187,=
 187); word-wrap: break-word;"><code class=3D"prettyprint"><span class=3D"s=
tyled-by-prettify" style=3D"color: rgb(0, 0, 136);">auto</span><span class=
=3D"styled-by-prettify" style=3D""><span class=3D"Apple-converted-space">&n=
bsp;</span>x<span class=3D"Apple-converted-space">&nbsp;</span></span><span=
 class=3D"styled-by-prettify" style=3D"color: rgb(102, 102, 0);">=3D</span>=
<span class=3D"Apple-converted-space">&nbsp;</span>make_array<span class=3D=
"styled-by-prettify" style=3D"color: rgb(102, 102, 0);">(</span>foo<span cl=
ass=3D"styled-by-prettify" style=3D"color: rgb(102, 102, 0);">());</span></=
code></div><br class=3D"">Or in an arbitrary data structure:<br class=3D"">=
<br class=3D""><div class=3D"prettyprint" style=3D"background-color: rgb(25=
0, 250, 250); border: 1px solid rgb(187, 187, 187); word-wrap: break-word;"=
><code class=3D"prettyprint"><span class=3D"styled-by-prettify" style=3D"co=
lor: rgb(0, 0, 136);">auto</span><span class=3D"styled-by-prettify" style=
=3D""><span class=3D"Apple-converted-space">&nbsp;</span>x<span class=3D"Ap=
ple-converted-space">&nbsp;</span></span><span class=3D"styled-by-prettify"=
 style=3D"color: rgb(102, 102, 0);">=3D</span><span class=3D"Apple-converte=
d-space">&nbsp;</span>std<span class=3D"styled-by-prettify" style=3D"color:=
 rgb(102, 102, 0);">::</span>vector<span class=3D"styled-by-prettify" style=
=3D"color: rgb(102, 102, 0);">&lt;</span><span class=3D"styled-by-prettify"=
 style=3D"color: rgb(102, 0, 102);">Type</span><span class=3D"styled-by-pre=
ttify" style=3D"color: rgb(102, 102, 0);">&gt;{</span>foo<span class=3D"sty=
led-by-prettify" style=3D"color: rgb(102, 102, 0);">()};</span><br class=3D=
""></code></div><br class=3D"">But most people using multiple return values=
 don't capture them in a big object, so we don't make the syntax optimal fo=
r that case.<br class=3D""><br class=3D""></div><blockquote class=3D"gmail_=
quote" style=3D"margin: 0px 0px 0px 0.8ex; border-left-width: 1px; border-l=
eft-color: rgb(204, 204, 204); border-left-style: solid; padding-left: 1ex;=
"><div dir=3D"ltr" class=3D""><div class=3D""></div></div></blockquote></di=
v></div></blockquote></div><div class=3D""><br class=3D""></div>I assume Ma=
tthew=E2=80=99s point comes from dealing with template code.<div class=3D""=
><br class=3D""></div><div class=3D"">template&lt;class F&gt;</div><div cla=
ss=3D"">??? contrived_example(F f) {</div><div class=3D"">&nbsp; &nbsp; ret=
urn f();</div><div class=3D"">}</div><div class=3D""><br class=3D""></div><=
div class=3D"">The author would probably expect that ??? can be plain =E2=
=80=9Cauto=E2=80=9D, implying =E2=80=9Cin some places auto can expand to mu=
ltiple types=E2=80=9D. Then there=E2=80=99s the point of what generic code =
would require to do to consistently capture the return value(s) of a Callab=
le without knowing if there are one or multiple return values.</div><div cl=
ass=3D""><br class=3D""></div><div class=3D"">template&lt;class F&gt;</div>=
<div class=3D"">void contrived_example2(F f) {</div><div class=3D"">&nbsp; =
&nbsp; ??? x =3D f();</div><div class=3D"">&nbsp; &nbsp; ...</div><div clas=
s=3D"">}</div><div class=3D""><br class=3D""></div><div class=3D"">Should ?=
?? be something that can potentially capture a single or multiple values de=
pending on the initialization? If so what can be done with x down the pipel=
ine? Or is a concept necessary to overload contrived_example2 for functions=
 with single or multiple return values? Is template code forced into packin=
g every Callable=E2=80=99s invocation into make_tuple() just in case it mig=
ht return multiple values?</div><div class=3D""><br class=3D""></div></body=
></html>

<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 />

--Apple-Mail=_3DF0C2DE-72E6-476C-99F6-D723A7EC6453--

.
