Topic: Multiple return values


Author: Hariharan Subramanian <tohari@gmail.com>
Date: Mon, 29 Apr 2013 07:03:16 -0700 (PDT)
Raw View
------=_Part_3796_26940885.1367244196978
Content-Type: text/plain; charset=ISO-8859-1

Problem:
Having a single return value means we have to pass the other return values
as parameters as a reference or a pointer. This makes the programs
difficult to understand. Moreover we can solve most of the problems
mentioned in
http://www.openstd.org/JTC1/SC22/WG21/docs/papers/2013/n3538.html<http://www.open-std.org/JTC1/SC22/WG21/docs/papers/2013/n3538.html>
..

Solution:
(int; float) foo (int);
Probably a contextual keyword returns can be added to specify that the
first pair of parentheses represents return values. So we will be passing
only in parameters and in out parameters to the function. All the out
parameters are only returned.

With this we can write the code

int a;
float b;
(a; b) = foo(a, b);
(int c; float d) = foo(a, b);

If foo returns int & instead of int then we need to write

(int &c; float d) = foo(a, b);

If we decide to ignore some return values we can use void for those return
values.

We can pass the return values to functions. We can write foo( foo(a, b) );

We can compare the return values. The semantics can be defined as the
operation should be true for all the return values.
foo(a,  b) == foo(c, d), foo(a, b) >= foo(c, d) etc.,

We cab do the following also
(c, d) == foo(a, b), (c, d) > foo(a, b) etc.,

(a, b) = (b, a) swaps the values. It should generate the code equivalent to

(float; int) dummy(float b, int a) {
     return (b, a);
}
(a, b) = dummy(b, a);

Move semantics can be used to assign. Hence we will not face the issue
mentioned in N3538 document if there are no in out parameters.

There are some problem areas like type casting. Probably they can be
prohibited. Other issues may remain and need to be discussed.

Probably multiple return values might have been discussed earlier.
Nevertheless, I wanted to give it a shot.

--

---
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.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposals/?hl=en.



------=_Part_3796_26940885.1367244196978
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable

Problem:<div>Having a single return value means we have to pass the other r=
eturn values as parameters as a reference or a pointer. This makes the prog=
rams difficult to understand. Moreover we can solve most of the problems me=
ntioned in&nbsp;<a href=3D"http://www.open-std.org/JTC1/SC22/WG21/docs/pape=
rs/2013/n3538.html">http://www.openstd.org/JTC1/SC22/WG21/docs/papers/2013/=
n3538.html</a>.&nbsp;</div><div><br></div><div>Solution:</div><div>(int; fl=
oat) foo (int);</div><div>Probably a contextual keyword returns can be adde=
d to specify that the first pair of parentheses represents return values. S=
o we will be passing only in parameters and in out parameters to the functi=
on. All the out parameters are only returned.</div><div><br></div><div>With=
 this we can write the code</div><div><br></div><div>int a;</div><div>float=
 b;</div><div>(a; b) =3D foo(a, b);</div><div>(int c; float d) =3D foo(a, b=
);</div><div><br></div><div>If foo returns int &amp; instead of int then we=
 need to write</div><div><br></div><div>(int &amp;c; float d) =3D foo(a, b)=
;</div><div><br></div><div>If we decide to ignore some return values we can=
 use void for those return values.</div><div><br></div><div>We can pass the=
 return values to functions. We can write foo( foo(a, b) );</div><div><br><=
/div><div>We can compare the return values. The semantics can be defined as=
 the operation should be true for all the return values.</div><div>foo(a, &=
nbsp;b) =3D=3D foo(c, d), foo(a, b) &gt;=3D foo(c, d) etc.,<br></div><div><=
br></div><div>We cab do the following also</div><div>(c, d) =3D=3D foo(a, b=
), (c, d) &gt; foo(a, b) etc.,</div><div><br></div><div>(a, b) =3D (b, a) s=
waps the values. It should generate the code equivalent to</div><div><br></=
div><div>(float; int) dummy(float b, int a) {</div><div>&nbsp; &nbsp; &nbsp=
;return (b, a);</div><div>}</div><div>(a, b) =3D dummy(b, a);</div><div><br=
></div><div>Move semantics can be used to assign. Hence we will not face th=
e issue mentioned in N3538 document if there are no in out parameters.</div=
><div><br></div><div>There are some problem areas like type casting. Probab=
ly they can be prohibited. Other issues may remain and need to be discussed=
..</div><div><br></div><div>Probably multiple return values might have been =
discussed earlier. Nevertheless, I wanted to give it a shot.</div><div><br>=
</div>

<p></p>

-- <br />
&nbsp;<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 std-proposals+unsubscribe@isocpp.org.<br />
To post to this group, send email to std-proposals@isocpp.org.<br />
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/?hl=3Den">http://groups.google.com/a/isocpp.org/group/std-pro=
posals/?hl=3Den</a>.<br />
&nbsp;<br />
&nbsp;<br />

------=_Part_3796_26940885.1367244196978--

.


Author: Ville Voutilainen <ville.voutilainen@gmail.com>
Date: Mon, 29 Apr 2013 17:04:54 +0300
Raw View
--089e01229c307d1fb204db805ef2
Content-Type: text/plain; charset=ISO-8859-1

On 29 April 2013 17:03, Hariharan Subramanian <tohari@gmail.com> wrote:

> Problem:
> Having a single return value means we have to pass the other return values
> as parameters as a reference or a pointer. This
>
>
Return a tuple.

Now, reconsider whether you still want to make a core language change. ;)

--

---
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.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposals/?hl=en.



--089e01229c307d1fb204db805ef2
Content-Type: text/html; charset=ISO-8859-1

<div dir="ltr"><br><div class="gmail_extra"><br><br><div class="gmail_quote">On 29 April 2013 17:03, Hariharan Subramanian <span dir="ltr">&lt;<a href="mailto:tohari@gmail.com" target="_blank">tohari@gmail.com</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Problem:<div>Having a single return value means we have to pass the other return values as parameters as a reference or a pointer. This<br>
<br></div></blockquote><div><br></div><div>Return a tuple.<br><br></div><div>Now, reconsider whether you still want to make a core language change. ;) <br></div></div><br></div></div>

<p></p>

-- <br />
&nbsp;<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 email to std-proposals+unsubscribe@isocpp.org.<br />
To post to this group, send email to std-proposals@isocpp.org.<br />
Visit this group at <a href="http://groups.google.com/a/isocpp.org/group/std-proposals/?hl=en">http://groups.google.com/a/isocpp.org/group/std-proposals/?hl=en</a>.<br />
&nbsp;<br />
&nbsp;<br />

--089e01229c307d1fb204db805ef2--

.


Author: DeadMG <wolfeinstein@gmail.com>
Date: Mon, 29 Apr 2013 07:09:41 -0700 (PDT)
Raw View
------=_Part_57_22261602.1367244581473
Content-Type: text/plain; charset=ISO-8859-1

He has a valid point, I think. Returning tuples and especially unpacking on
the other end isn't as easy as it could be in some languages with core
language support for this- for example, Lua.

--

---
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.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposals/?hl=en.



------=_Part_57_22261602.1367244581473
Content-Type: text/html; charset=ISO-8859-1

He has a valid point, I think. Returning tuples and especially unpacking on the other end isn't as easy as it could be in some languages with core language support for this- for example, Lua.

<p></p>

-- <br />
&nbsp;<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 email to std-proposals+unsubscribe@isocpp.org.<br />
To post to this group, send email to std-proposals@isocpp.org.<br />
Visit this group at <a href="http://groups.google.com/a/isocpp.org/group/std-proposals/?hl=en">http://groups.google.com/a/isocpp.org/group/std-proposals/?hl=en</a>.<br />
&nbsp;<br />
&nbsp;<br />

------=_Part_57_22261602.1367244581473--

.


Author: Ville Voutilainen <ville.voutilainen@gmail.com>
Date: Mon, 29 Apr 2013 17:15:46 +0300
Raw View
--f46d044789055f218e04db8085e2
Content-Type: text/plain; charset=ISO-8859-1

On 29 April 2013 17:09, DeadMG <wolfeinstein@gmail.com> wrote:

> He has a valid point, I think. Returning tuples and especially unpacking
> on the other end isn't as easy as it could be in some languages with core
> language support for this- for example, Lua.
>
>
>
>
Perhaps so. I'm just pointing out in a rather friendly manner that adding
such core language support may end
up being an uphill battle.

--

---
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.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposals/?hl=en.



--f46d044789055f218e04db8085e2
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><br><div class=3D"gmail_extra"><br><br><div class=3D"gmail=
_quote">On 29 April 2013 17:09, DeadMG <span dir=3D"ltr">&lt;<a href=3D"mai=
lto:wolfeinstein@gmail.com" target=3D"_blank">wolfeinstein@gmail.com</a>&gt=
;</span> wrote:<br>
<blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1p=
x #ccc solid;padding-left:1ex">He has a valid point, I think. Returning tup=
les and especially unpacking on the other end isn&#39;t as easy as it could=
 be in some languages with core language support for this- for example, Lua=
..

<div class=3D"HOEnZb"><div class=3D"h5"><p></p>

<br><br></div></div></blockquote><div><br></div><div>Perhaps so. I&#39;m ju=
st pointing out in a rather friendly manner that adding such core language =
support may end<br>up being an uphill battle. <br></div></div><br></div>
</div>

<p></p>

-- <br />
&nbsp;<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 std-proposals+unsubscribe@isocpp.org.<br />
To post to this group, send email to std-proposals@isocpp.org.<br />
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/?hl=3Den">http://groups.google.com/a/isocpp.org/group/std-pro=
posals/?hl=3Den</a>.<br />
&nbsp;<br />
&nbsp;<br />

--f46d044789055f218e04db8085e2--

.


Author: DeadMG <wolfeinstein@gmail.com>
Date: Mon, 29 Apr 2013 07:19:45 -0700 (PDT)
Raw View
------=_Part_246_10418929.1367245185283
Content-Type: text/plain; charset=ISO-8859-1

I agree. I'm not saying that there is a core feature that will work for
C++, since language-level support for tuples covers a whole lot more than
his simple use case (although it could, potentially, be used to fix the
very broken uniform initialization). What I am saying is that it's not a
problem which is entirely solved by std::tuple, and it would be a desirable
feature to have.

--

---
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.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposals/?hl=en.



------=_Part_246_10418929.1367245185283
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable

I agree. I'm not saying that there is a core feature that will work for C++=
, since language-level support for tuples covers a whole lot more than his =
simple use case (although it could, potentially, be used to fix the very br=
oken uniform initialization). What I am saying is that it's not a problem w=
hich is entirely solved by std::tuple, and it would be a desirable feature =
to have.

<p></p>

-- <br />
&nbsp;<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 std-proposals+unsubscribe@isocpp.org.<br />
To post to this group, send email to std-proposals@isocpp.org.<br />
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/?hl=3Den">http://groups.google.com/a/isocpp.org/group/std-pro=
posals/?hl=3Den</a>.<br />
&nbsp;<br />
&nbsp;<br />

------=_Part_246_10418929.1367245185283--

.


Author: Christopher Jefferson <chris@bubblescope.net>
Date: Mon, 29 Apr 2013 16:33:22 +0100
Raw View
--047d7b6d89a2deee8b04db819a6e
Content-Type: text/plain; charset=ISO-8859-1

On 29 April 2013 15:03, Hariharan Subramanian <tohari@gmail.com> wrote:

> Problem:
> Having a single return value means we have to pass the other return values
> as parameters as a reference or a pointer. This makes the programs
> difficult to understand. Moreover we can solve most of the problems
> mentioned in
> http://www.openstd.org/JTC1/SC22/WG21/docs/papers/2013/n3538.html<http://www.open-std.org/JTC1/SC22/WG21/docs/papers/2013/n3538.html>
> .
>

I decided to have a go at seeing how much of this could be done with
std::tuple.

>
> Solution:
> (int; float) foo (int);
>
std::tuple<int, float> foo(int);

> Probably a contextual keyword returns can be added to specify that the
> first pair of parentheses represents return values. So we will be passing
> only in parameters and in out parameters to the function. All the out
> parameters are only returned.
>
> With this we can write the code
>
> int a;
> float b;
> (a; b) = foo(a, b);
>
std::tie(a,b) = foo(a,b);

> (int c; float d) = foo(a, b);
>
This one we have to write:
int c; float d;
std::tie(c, d) = foo(a,b);

>
> We can pass the return values to functions. We can write foo( foo(a, b) );
>
Now you are automatically unpacking tuples. What happens if foo takes a
tuple? This case doesn't work, but you have to be careful.

>
> We can compare the return values. The semantics can be defined as the
> operation should be true for all the return values.
> foo(a,  b) == foo(c, d), foo(a, b) >= foo(c, d) etc.,
>
Works with std::tuple already

>
> We cab do the following also
> (c, d) == foo(a, b), (c, d) > foo(a, b) etc.,
>
std::tie(c,d) == foo(a,b), std::tie(c,d) > foo(a,b);

>
> (a, b) = (b, a) swaps the values. It should generate the code equivalent to
>
This one, I wouldn't be confident doing with tie (but it might work).
However, we have swap :)



> There are some problem areas like type casting. Probably they can be
> prohibited. Other issues may remain and need to be discussed.
>

The main problem (as I outline in my mail) is that many of these things can
be done with std::tuple and std::tie. If this is just syntatic sugar over
std::tuple and std::tie, then is it worth it, and if it is a seperate kind
of tuple, we have to worry about the two interacting.

--

---
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.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposals/?hl=en.



--047d7b6d89a2deee8b04db819a6e
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><br><div class=3D"gmail_extra"><br><br><div class=3D"gmail=
_quote">On 29 April 2013 15:03, Hariharan Subramanian <span dir=3D"ltr">&lt=
;<a href=3D"mailto:tohari@gmail.com" target=3D"_blank">tohari@gmail.com</a>=
&gt;</span> wrote:<br>
<blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1p=
x #ccc solid;padding-left:1ex">Problem:<div>Having a single return value me=
ans we have to pass the other return values as parameters as a reference or=
 a pointer. This makes the programs difficult to understand. Moreover we ca=
n solve most of the problems mentioned in=A0<a href=3D"http://www.open-std.=
org/JTC1/SC22/WG21/docs/papers/2013/n3538.html" target=3D"_blank">http://ww=
w.openstd.org/JTC1/SC22/WG21/docs/papers/2013/n3538.html</a>.=A0</div>
</blockquote><div><br></div><div style>I decided to have a go at seeing how=
 much of this could be done with std::tuple.=A0</div><blockquote class=3D"g=
mail_quote" style=3D"margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-l=
eft:1ex">
<div><br></div><div>Solution:</div><div>(int; float) foo (int);</div></bloc=
kquote><div style>std::tuple&lt;int, float&gt; foo(int);=A0</div><blockquot=
e class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1px #ccc sol=
id;padding-left:1ex">
<div>Probably a contextual keyword returns can be added to specify that the=
 first pair of parentheses represents return values. So we will be passing =
only in parameters and in out parameters to the function. All the out param=
eters are only returned.</div>
<div><br></div><div>With this we can write the code</div><div><br></div><di=
v>int a;</div><div>float b;</div><div>(a; b) =3D foo(a, b);</div></blockquo=
te><div style>std::tie(a,b) =3D foo(a,b);=A0</div><blockquote class=3D"gmai=
l_quote" style=3D"margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left=
:1ex">
<div>(int c; float d) =3D foo(a, b);</div></blockquote><div style>This one =
we have to write:</div><div style>int c; float d;</div><div style>std::tie(=
c, d) =3D foo(a,b);=A0</div><blockquote class=3D"gmail_quote" style=3D"marg=
in:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div><br></div><div>We can pass the return values to functions. We can writ=
e foo( foo(a, b) );<br></div></blockquote><div style>Now you are automatica=
lly unpacking tuples. What happens if foo takes a tuple? This case doesn&#3=
9;t work, but you have to be careful.=A0</div>
<blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1p=
x #ccc solid;padding-left:1ex"><div><br></div><div>We can compare the retur=
n values. The semantics can be defined as the operation should be true for =
all the return values.</div>
<div>foo(a, =A0b) =3D=3D foo(c, d), foo(a, b) &gt;=3D foo(c, d) etc.,<br></=
div></blockquote><div style>Works with std::tuple already</div><blockquote =
class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1px #ccc solid=
;padding-left:1ex">
<div></div><div><br></div><div>We cab do the following also</div><div>(c, d=
) =3D=3D foo(a, b), (c, d) &gt; foo(a, b) etc.,</div></blockquote><div styl=
e>std::tie(c,d) =3D=3D foo(a,b), std::tie(c,d) &gt; foo(a,b);=A0</div><bloc=
kquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1px #cc=
c solid;padding-left:1ex">
<div><br></div><div>(a, b) =3D (b, a) swaps the values. It should generate =
the code equivalent to</div></blockquote><div style>This one, I wouldn&#39;=
t be confident doing with tie (but it might work). However, we have swap :)=
=A0</div>
<div><br></div><div>=A0<br></div><blockquote class=3D"gmail_quote" style=3D=
"margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div>There =
are some problem areas like type casting. Probably they can be prohibited. =
Other issues may remain and need to be discussed.<br>
</div></blockquote><div><br></div><div style>The main problem (as I outline=
 in my mail) is that many of these things can be done with std::tuple and s=
td::tie. If this is just syntatic sugar over std::tuple and std::tie, then =
is it worth it, and if it is a seperate kind of tuple, we have to worry abo=
ut the two interacting.</div>
</div></div></div>

<p></p>

-- <br />
&nbsp;<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 std-proposals+unsubscribe@isocpp.org.<br />
To post to this group, send email to std-proposals@isocpp.org.<br />
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/?hl=3Den">http://groups.google.com/a/isocpp.org/group/std-pro=
posals/?hl=3Den</a>.<br />
&nbsp;<br />
&nbsp;<br />

--047d7b6d89a2deee8b04db819a6e--

.


Author: Hariharan Subramanian <tohari@gmail.com>
Date: Tue, 30 Apr 2013 10:36:23 +0530
Raw View
--001a11c34f4076d97304db8cf67c
Content-Type: text/plain; charset=ISO-8859-1

I wrote the proposal without considering the suggested alternatives. Hence
I would like to withdraw this proposal. Thanks for suggesting the
alternatives.

Hariharan S


On Mon, Apr 29, 2013 at 7:49 PM, DeadMG <wolfeinstein@gmail.com> wrote:

> I agree. I'm not saying that there is a core feature that will work for
> C++, since language-level support for tuples covers a whole lot more than
> his simple use case (although it could, potentially, be used to fix the
> very broken uniform initialization). What I am saying is that it's not a
> problem which is entirely solved by std::tuple, and it would be a desirable
> feature to have.
>
> --
>
> ---
> You received this message because you are subscribed to a topic in the
> Google Groups "ISO C++ Standard - Future Proposals" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/a/isocpp.org/d/topic/std-proposals/VROimyg83fc/unsubscribe?hl=en
> .
> To unsubscribe from this group and all its topics, send an email 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-proposals/?hl=en.
>
>
>

--

---
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.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposals/?hl=en.



--001a11c34f4076d97304db8cf67c
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr">I wrote the proposal without considering the suggested alt=
ernatives. Hence I would like to withdraw this proposal. Thanks for suggest=
ing the alternatives.<div><br></div><div style>Hariharan S</div></div><div =
class=3D"gmail_extra">
<br><br><div class=3D"gmail_quote">On Mon, Apr 29, 2013 at 7:49 PM, DeadMG =
<span dir=3D"ltr">&lt;<a href=3D"mailto:wolfeinstein@gmail.com" target=3D"_=
blank">wolfeinstein@gmail.com</a>&gt;</span> wrote:<br><blockquote class=3D=
"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1px #ccc solid;padding=
-left:1ex">
I agree. I&#39;m not saying that there is a core feature that will work for=
 C++, since language-level support for tuples covers a whole lot more than =
his simple use case (although it could, potentially, be used to fix the ver=
y broken uniform initialization). What I am saying is that it&#39;s not a p=
roblem which is entirely solved by std::tuple, and it would be a desirable =
feature to have.

<div class=3D"HOEnZb"><div class=3D"h5"><p></p>

-- <br>
=A0<br>
--- <br>
You received this message because you are subscribed to a topic in the Goog=
le Groups &quot;ISO C++ Standard - Future Proposals&quot; group.<br>
To unsubscribe from this topic, visit <a href=3D"https://groups.google.com/=
a/isocpp.org/d/topic/std-proposals/VROimyg83fc/unsubscribe?hl=3Den" target=
=3D"_blank">https://groups.google.com/a/isocpp.org/d/topic/std-proposals/VR=
Oimyg83fc/unsubscribe?hl=3Den</a>.<br>

To unsubscribe from this group and all its topics, send an email to <a href=
=3D"mailto:std-proposals%2Bunsubscribe@isocpp.org" target=3D"_blank">std-pr=
oposals+unsubscribe@isocpp.org</a>.<br>
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org" target=3D"_blank">std-proposals@isocpp.org</a>.<br>
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/?hl=3Den" target=3D"_blank">http://groups.google.com/a/isocpp=
..org/group/std-proposals/?hl=3Den</a>.<br>
=A0<br>
=A0<br>
</div></div></blockquote></div><br></div>

<p></p>

-- <br />
&nbsp;<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 std-proposals+unsubscribe@isocpp.org.<br />
To post to this group, send email to std-proposals@isocpp.org.<br />
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/?hl=3Den">http://groups.google.com/a/isocpp.org/group/std-pro=
posals/?hl=3Den</a>.<br />
&nbsp;<br />
&nbsp;<br />

--001a11c34f4076d97304db8cf67c--

.


Author: morwenn29@gmail.com
Date: Tue, 30 Apr 2013 04:07:51 -0700 (PDT)
Raw View
------=_Part_2410_15974924.1367320071326
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable

If you want to think about core tuples in a C-like programming language,=20
you better have a look at how it was done in Alef first:
http://en.wikipedia.org/wiki/Alef_%28programming_language%29

And we can also think at how (1, 2) is a tuple in Python also, (1) is not,=
=20
but (1,) is and try to think about all the problems linked to parsing this=
=20
kind of tuples in C++;

Le lundi 29 avril 2013 16:03:16 UTC+2, Hariharan Subramanian a =E9crit :
>
> Problem:
> Having a single return value means we have to pass the other return value=
s=20
> as parameters as a reference or a pointer. This makes the programs=20
> difficult to understand. Moreover we can solve most of the problems=20
> mentioned in=20
> http://www.openstd.org/JTC1/SC22/WG21/docs/papers/2013/n3538.html<http://=
www.open-std.org/JTC1/SC22/WG21/docs/papers/2013/n3538.html>
> .=20
>
> Solution:
> (int; float) foo (int);
> Probably a contextual keyword returns can be added to specify that the=20
> first pair of parentheses represents return values. So we will be passing=
=20
> only in parameters and in out parameters to the function. All the out=20
> parameters are only returned.
>
> With this we can write the code
>
> int a;
> float b;
> (a; b) =3D foo(a, b);
> (int c; float d) =3D foo(a, b);
>
> If foo returns int & instead of int then we need to write
>
> (int &c; float d) =3D foo(a, b);
>
> If we decide to ignore some return values we can use void for those retur=
n=20
> values.
>
> We can pass the return values to functions. We can write foo( foo(a, b) )=
;
>
> We can compare the return values. The semantics can be defined as the=20
> operation should be true for all the return values.
> foo(a,  b) =3D=3D foo(c, d), foo(a, b) >=3D foo(c, d) etc.,
>
> We cab do the following also
> (c, d) =3D=3D foo(a, b), (c, d) > foo(a, b) etc.,
>
> (a, b) =3D (b, a) swaps the values. It should generate the code equivalen=
t to
>
> (float; int) dummy(float b, int a) {
>      return (b, a);
> }
> (a, b) =3D dummy(b, a);
>
> Move semantics can be used to assign. Hence we will not face the issue=20
> mentioned in N3538 document if there are no in out parameters.
>
> There are some problem areas like type casting. Probably they can be=20
> prohibited. Other issues may remain and need to be discussed.
>
> Probably multiple return values might have been discussed earlier.=20
> Nevertheless, I wanted to give it a shot.
>
>

--=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/?hl=3Den.



------=_Part_2410_15974924.1367320071326
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable

If you want to think about core tuples in a C-like programming language, yo=
u better have a look at how it was done in Alef first:<br>http://en.wikiped=
ia.org/wiki/Alef_%28programming_language%29<br><br>And we can also think at=
 how (1, 2) is a tuple in Python also, (1) is not, but (1,) is and try to t=
hink about all the problems linked to parsing this kind of tuples in C++;<b=
r><br>Le lundi 29 avril 2013 16:03:16 UTC+2, Hariharan Subramanian a =E9cri=
t&nbsp;:<blockquote class=3D"gmail_quote" style=3D"margin: 0;margin-left: 0=
..8ex;border-left: 1px #ccc solid;padding-left: 1ex;">Problem:<div>Having a =
single return value means we have to pass the other return values as parame=
ters as a reference or a pointer. This makes the programs difficult to unde=
rstand. Moreover we can solve most of the problems mentioned in&nbsp;<a hre=
f=3D"http://www.open-std.org/JTC1/SC22/WG21/docs/papers/2013/n3538.html" ta=
rget=3D"_blank">http://www.openstd.org/<wbr>JTC1/SC22/WG21/docs/papers/<wbr=
>2013/n3538.html</a>.&nbsp;</div><div><br></div><div>Solution:</div><div>(i=
nt; float) foo (int);</div><div>Probably a contextual keyword returns can b=
e added to specify that the first pair of parentheses represents return val=
ues. So we will be passing only in parameters and in out parameters to the =
function. All the out parameters are only returned.</div><div><br></div><di=
v>With this we can write the code</div><div><br></div><div>int a;</div><div=
>float b;</div><div>(a; b) =3D foo(a, b);</div><div>(int c; float d) =3D fo=
o(a, b);</div><div><br></div><div>If foo returns int &amp; instead of int t=
hen we need to write</div><div><br></div><div>(int &amp;c; float d) =3D foo=
(a, b);</div><div><br></div><div>If we decide to ignore some return values =
we can use void for those return values.</div><div><br></div><div>We can pa=
ss the return values to functions. We can write foo( foo(a, b) );</div><div=
><br></div><div>We can compare the return values. The semantics can be defi=
ned as the operation should be true for all the return values.</div><div>fo=
o(a, &nbsp;b) =3D=3D foo(c, d), foo(a, b) &gt;=3D foo(c, d) etc.,<br></div>=
<div><br></div><div>We cab do the following also</div><div>(c, d) =3D=3D fo=
o(a, b), (c, d) &gt; foo(a, b) etc.,</div><div><br></div><div>(a, b) =3D (b=
, a) swaps the values. It should generate the code equivalent to</div><div>=
<br></div><div>(float; int) dummy(float b, int a) {</div><div>&nbsp; &nbsp;=
 &nbsp;return (b, a);</div><div>}</div><div>(a, b) =3D dummy(b, a);</div><d=
iv><br></div><div>Move semantics can be used to assign. Hence we will not f=
ace the issue mentioned in N3538 document if there are no in out parameters=
..</div><div><br></div><div>There are some problem areas like type casting. =
Probably they can be prohibited. Other issues may remain and need to be dis=
cussed.</div><div><br></div><div>Probably multiple return values might have=
 been discussed earlier. Nevertheless, I wanted to give it a shot.</div><di=
v><br></div></blockquote>

<p></p>

-- <br />
&nbsp;<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 std-proposals+unsubscribe@isocpp.org.<br />
To post to this group, send email to std-proposals@isocpp.org.<br />
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/?hl=3Den">http://groups.google.com/a/isocpp.org/group/std-pro=
posals/?hl=3Den</a>.<br />
&nbsp;<br />
&nbsp;<br />

------=_Part_2410_15974924.1367320071326--

.


Author: unituniverse.1@gmail.com
Date: Tue, 7 May 2013 13:33:17 -0700 (PDT)
Raw View
------=_Part_3271_2154335.1367958797875
Content-Type: text/plain; charset=ISO-8859-1

it's so hard to implement what you asked into C++ than you thought. To C,
it's may be much easier.
What the function returns must be a ensured Type.
    Then what the type of (int c, fload d)?
You can't just ignore this question because the templates decoding and
something else need it.
Say:
 auto retval = func(a, b); // What's the type of retval?
 decltype(retval) val2(retval); // Even you can give a hidden type to
retval, what should happen at this line??
val2 = retval;// Even you can give a hidden type to retval, what should
happen at this line??
typedef decltype(func(a,b)) T1; // What the T1 should be?
You can't treat the func as a special kind of function simply, because the
function will be passed to templates, many rules should be modified.

--

---
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.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposals/?hl=en.



------=_Part_3271_2154335.1367958797875
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable

<div>it's so hard to implement what you asked into C++ than you thought. To=
 C, it's may be much easier.</div><div>What the function returns must be a =
ensured Type.</div><div>&nbsp; &nbsp; Then what the type of (int c, fload d=
)?</div><div>You can't just ignore this question because the templates deco=
ding and something else need it.</div><div>Say:</div><div>&nbsp;auto retval=
 =3D func(a, b); // What's the type of retval?</div><div>&nbsp;decltype(ret=
val) val2(retval); // Even you can give a hidden type to retval, what shoul=
d happen at this line??</div><div>val2 =3D retval;// Even you can give a hi=
dden type to retval, what should happen at this line??</div><div>typedef de=
cltype(func(a,b)) T1; // What the T1 should be?</div><div>You can't treat t=
he func as a special kind of function simply, because the function will be =
passed to templates, many rules should be modified.</div><div><br></div>

<p></p>

-- <br />
&nbsp;<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 std-proposals+unsubscribe@isocpp.org.<br />
To post to this group, send email to std-proposals@isocpp.org.<br />
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/?hl=3Den">http://groups.google.com/a/isocpp.org/group/std-pro=
posals/?hl=3Den</a>.<br />
&nbsp;<br />
&nbsp;<br />

------=_Part_3271_2154335.1367958797875--

.


Author: Tony V E <tvaneerd@gmail.com>
Date: Fri, 10 May 2013 13:16:44 -0400
Raw View
--089e01161a44cf1dad04dc6054d6
Content-Type: text/plain; charset=ISO-8859-1

On Tue, May 7, 2013 at 4:33 PM, <unituniverse.1@gmail.com> wrote:

> it's so hard to implement what you asked into C++ than you thought. To C,
> it's may be much easier.
> What the function returns must be a ensured Type.
>     Then what the type of (int c, fload d)?
> You can't just ignore this question because the templates decoding and
> something else need it.
> Say:
>  auto retval = func(a, b); // What's the type of retval?
>  decltype(retval) val2(retval); // Even you can give a hidden type to
> retval, what should happen at this line??
> val2 = retval;// Even you can give a hidden type to retval, what should
> happen at this line??
> typedef decltype(func(a,b)) T1; // What the T1 should be?
> You can't treat the func as a special kind of function simply, because the
> function will be passed to templates, many rules should be modified.
>
>  --
>
>

Not sure how feasible it is, but I'd love to use tuples for all of this,
with {a,b,c} syntax to mean 'tuple'.

auto f() { return { 1, 2, "three" }; }  // auto == tuple<int,int,char const
*>

int a, b;
char const * c;

{ a, b, c } = f();  // works like std::tie()

etc.

Not sure about the best way of declaring a,b,c within the brackets.

{ int a; }

is already valid syntax.

--

---
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.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposals/?hl=en.



--089e01161a44cf1dad04dc6054d6
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><br><div class=3D"gmail_extra"><br><br><div class=3D"gmail=
_quote">On Tue, May 7, 2013 at 4:33 PM,  <span dir=3D"ltr">&lt;<a href=3D"m=
ailto:unituniverse.1@gmail.com" target=3D"_blank">unituniverse.1@gmail.com<=
/a>&gt;</span> wrote:<br>
<blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1p=
x #ccc solid;padding-left:1ex"><div>it&#39;s so hard to implement what you =
asked into C++ than you thought. To C, it&#39;s may be much easier.</div><d=
iv>
What the function returns must be a ensured Type.</div><div>=A0 =A0 Then wh=
at the type of (int c, fload d)?</div><div>You can&#39;t just ignore this q=
uestion because the templates decoding and something else need it.</div><di=
v>
Say:</div><div>=A0auto retval =3D func(a, b); // What&#39;s the type of ret=
val?</div><div>=A0decltype(retval) val2(retval); // Even you can give a hid=
den type to retval, what should happen at this line??</div><div>val2 =3D re=
tval;// Even you can give a hidden type to retval, what should happen at th=
is line??</div>
<div>typedef decltype(func(a,b)) T1; // What the T1 should be?</div><div>Yo=
u can&#39;t treat the func as a special kind of function simply, because th=
e function will be passed to templates, many rules should be modified.</div=
>
<div class=3D"HOEnZb"><div class=3D"h5"><div><br></div>

<p></p>

-- <br>=A0
<br></div></div></blockquote><div><br></div><div>Not sure how feasible it i=
s, but I&#39;d love to use tuples for all of this, with {a,b,c} syntax to m=
ean &#39;tuple&#39;.<br><br></div><div>auto f() { return { 1, 2, &quot;thre=
e&quot; }; }=A0 // auto =3D=3D tuple&lt;int,int,char const *&gt;<br>
<br></div><div>int a, b;<br></div><div>char const * c;<br><br></div><div>{ =
a, b, c } =3D f();=A0 // works like std::tie()<br><br></div><div>etc.<br><b=
r></div><div>Not sure about the best way of declaring a,b,c within the brac=
kets.<br>
<br></div><div>{ int a; }<br><br>is already valid syntax.<br></div><br><div=
>=A0</div></div></div></div>

<p></p>

-- <br />
&nbsp;<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 std-proposals+unsubscribe@isocpp.org.<br />
To post to this group, send email to std-proposals@isocpp.org.<br />
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/?hl=3Den">http://groups.google.com/a/isocpp.org/group/std-pro=
posals/?hl=3Den</a>.<br />
&nbsp;<br />
&nbsp;<br />

--089e01161a44cf1dad04dc6054d6--

.


Author: Richard Smith <richard@metafoo.co.uk>
Date: Fri, 10 May 2013 11:48:58 -0700
Raw View
--047d7b6dce12ad301b04dc619eb1
Content-Type: text/plain; charset=ISO-8859-1

On Fri, May 10, 2013 at 10:16 AM, Tony V E <tvaneerd@gmail.com> wrote:

> On Tue, May 7, 2013 at 4:33 PM, <unituniverse.1@gmail.com> wrote:
>
>> it's so hard to implement what you asked into C++ than you thought. To C,
>> it's may be much easier.
>> What the function returns must be a ensured Type.
>>     Then what the type of (int c, fload d)?
>> You can't just ignore this question because the templates decoding and
>> something else need it.
>> Say:
>>  auto retval = func(a, b); // What's the type of retval?
>>  decltype(retval) val2(retval); // Even you can give a hidden type to
>> retval, what should happen at this line??
>> val2 = retval;// Even you can give a hidden type to retval, what should
>> happen at this line??
>> typedef decltype(func(a,b)) T1; // What the T1 should be?
>> You can't treat the func as a special kind of function simply, because
>> the function will be passed to templates, many rules should be modified.
>>
>>  --
>>
>>
>
> Not sure how feasible it is, but I'd love to use tuples for all of this,
> with {a,b,c} syntax to mean 'tuple'.
>
> auto f() { return { 1, 2, "three" }; }  // auto == tuple<int,int,char
> const *>
>
> int a, b;
> char const * c;
>
> { a, b, c } = f();  // works like std::tie()
>
> etc.
>
> Not sure about the best way of declaring a,b,c within the brackets.
>
> { int a; }
>
> is already valid syntax.
>

An expression starting with '{' is certainly problematic. The problem here
isn't so much how to parse it (that actually turns out to be tractable with
basically no overhead and no extra lookahead) but more that it seriously
harms diagnostics and error recovery in some important cases. There are
some genuinely ambiguous cases, too, if we allow the general form:

  {} + x; // empty compound-statement followed by unary operator, or binary
operator with empty braced-init-list on LHS?

Using parens, as the original proposal suggests, may avoid this particular
problem, but I strongly suspect there will still be ambiguities.


I've been experimenting with a different approach to this problem: allow a
restricted form of simple-declaration as an lvalue expression, then:

  std::tie(int a, int b, const char *c) = f();

This also lessens the need to use tuples at all, since you can write
out-parameters like this:

  f(int a, int b, const char *c);

This still has some harmful impact on error recovery (the above could be a
declaration of 'f' missing a return type, for instance), and it requires
restricting the declarator forms to avoid declaration/expression ambiguity
for cases like 'f(int(a))'.

Both this and the "{ a, b, c } = " form have an additional (potentially
significant) problem: they require a, b, and c to be default-constructible
and move-assignable.


Given the alternatives in the design space, returning a tuple and capturing
it with 'auto' seems reasonable to me, aside from the syntactic
inconvenience of accessing a tuple element. If the caller needs names for
the fields, maybe returning a tuple with unnamed fields was a poor design
choice, and returning a struct would be a better option?

--

---
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.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposals/?hl=en.



--047d7b6dce12ad301b04dc619eb1
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable

On Fri, May 10, 2013 at 10:16 AM, Tony V E <span dir=3D"ltr">&lt;<a href=3D=
"mailto:tvaneerd@gmail.com" target=3D"_blank">tvaneerd@gmail.com</a>&gt;</s=
pan> wrote:<div class=3D"gmail_quote"><blockquote class=3D"gmail_quote" sty=
le=3D"margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div dir=3D"ltr"><div class=3D"gmail_extra"><div class=3D"gmail_quote"><div=
 class=3D"im">On Tue, May 7, 2013 at 4:33 PM,  <span dir=3D"ltr">&lt;<a hre=
f=3D"mailto:unituniverse.1@gmail.com" target=3D"_blank">unituniverse.1@gmai=
l.com</a>&gt;</span> wrote:<br>

<blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1p=
x #ccc solid;padding-left:1ex"><div>it&#39;s so hard to implement what you =
asked into C++ than you thought. To C, it&#39;s may be much easier.</div><d=
iv>

What the function returns must be a ensured Type.</div><div>=A0 =A0 Then wh=
at the type of (int c, fload d)?</div><div>You can&#39;t just ignore this q=
uestion because the templates decoding and something else need it.</div><di=
v>

Say:</div><div>=A0auto retval =3D func(a, b); // What&#39;s the type of ret=
val?</div><div>=A0decltype(retval) val2(retval); // Even you can give a hid=
den type to retval, what should happen at this line??</div><div>val2 =3D re=
tval;// Even you can give a hidden type to retval, what should happen at th=
is line??</div>

<div>typedef decltype(func(a,b)) T1; // What the T1 should be?</div><div>Yo=
u can&#39;t treat the func as a special kind of function simply, because th=
e function will be passed to templates, many rules should be modified.</div=
>

<div><div><div><br></div>

<p></p>

-- <br>=A0
<br></div></div></blockquote><div><br></div></div><div>Not sure how feasibl=
e it is, but I&#39;d love to use tuples for all of this, with {a,b,c} synta=
x to mean &#39;tuple&#39;.<br><br></div><div>auto f() { return { 1, 2, &quo=
t;three&quot; }; }=A0 // auto =3D=3D tuple&lt;int,int,char const *&gt;<br>

<br></div><div>int a, b;<br></div><div>char const * c;<br><br></div><div>{ =
a, b, c } =3D f();=A0 // works like std::tie()<br><br></div><div>etc.<br><b=
r></div><div>Not sure about the best way of declaring a,b,c within the brac=
kets.<br>

<br></div><div>{ int a; }<br><br>is already valid syntax.</div></div></div>=
</div></blockquote><div><br></div><div>An expression starting with &#39;{&#=
39; is certainly problematic. The problem here isn&#39;t so much how to par=
se it (that actually turns out to be tractable with basically no overhead a=
nd no extra lookahead) but more that it seriously harms diagnostics and err=
or recovery in some important cases. There are some genuinely ambiguous cas=
es, too, if we allow the general form:</div>
<div><br></div><div>=A0 {} + x; // empty compound-statement followed by una=
ry operator, or binary operator with empty braced-init-list on LHS?</div><d=
iv><br></div><div>Using parens, as the original proposal suggests, may avoi=
d this particular problem, but I strongly suspect there will still be ambig=
uities.</div>
<div><br></div><div><br></div><div>I&#39;ve been experimenting with a diffe=
rent approach to this problem: allow a restricted form of simple-declaratio=
n as an lvalue expression, then:</div><div><br></div><div>=A0 std::tie(int =
a, int b, const char *c) =3D f();</div>
<div><br></div><div>This also lessens the need to use tuples at all, since =
you can write out-parameters like this:</div><div><br></div><div>=A0 f(int =
a, int b, const char *c);</div><div><br></div><div>This still has some harm=
ful impact on error recovery (the above could be a declaration of &#39;f&#3=
9; missing a return type, for instance), and it requires restricting the de=
clarator forms to avoid declaration/expression ambiguity for cases like &#3=
9;f(int(a))&#39;.</div>
<div><br></div><div>Both this and the &quot;{ a, b, c } =3D &quot; form hav=
e an additional (potentially significant) problem: they require a, b, and c=
 to be default-constructible and move-assignable.</div><div><br></div><div>
<br></div><div>Given the alternatives in the design space, returning a tupl=
e and capturing it with &#39;auto&#39; seems reasonable to me, aside from t=
he syntactic inconvenience of accessing a tuple element. If the caller need=
s names for the fields, maybe returning a tuple with unnamed fields was a p=
oor design choice, and returning a struct would be a better option?</div>
</div>

<p></p>

-- <br />
&nbsp;<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 std-proposals+unsubscribe@isocpp.org.<br />
To post to this group, send email to std-proposals@isocpp.org.<br />
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/?hl=3Den">http://groups.google.com/a/isocpp.org/group/std-pro=
posals/?hl=3Den</a>.<br />
&nbsp;<br />
&nbsp;<br />

--047d7b6dce12ad301b04dc619eb1--

.


Author: Tony V E <tvaneerd@gmail.com>
Date: Fri, 10 May 2013 22:24:21 -0400
Raw View
--089e012281b43b1cfe04dc67fb85
Content-Type: text/plain; charset=ISO-8859-1

On Fri, May 10, 2013 at 2:48 PM, Richard Smith <richard@metafoo.co.uk>wrote:

>
>
> An expression starting with '{' is certainly problematic. The problem here
> isn't so much how to parse it (that actually turns out to be tractable with
> basically no overhead and no extra lookahead) but more that it seriously
> harms diagnostics and error recovery in some important cases. There are
> some genuinely ambiguous cases, too, if we allow the general form:
>
>   {} + x; // empty compound-statement followed by unary operator, or
> binary operator with empty braced-init-list on LHS?
>
>
I'd like to pretend that is:

   std::tuple<>() + x;



> Using parens, as the original proposal suggests, may avoid this particular
> problem, but I strongly suspect there will still be ambiguities.
>
>
We could always use some new parens.  ie {: a, b, c :}  or happy faces or
other emoticons.


>
> I've been experimenting with a different approach to this problem: allow a
> restricted form of simple-declaration as an lvalue expression, then:
>
>   std::tie(int a, int b, const char *c) = f();
>
> This also lessens the need to use tuples at all, since you can write
> out-parameters like this:
>
>   f(int a, int b, const char *c);
>
>
That doesn't look very out-ish to me at first glance.



> This still has some harmful impact on error recovery (the above could be a
> declaration of 'f' missing a return type, for instance), and it requires
> restricting the declarator forms to avoid declaration/expression ambiguity
> for cases like 'f(int(a))'.
>
> Both this and the "{ a, b, c } = " form have an additional (potentially
> significant) problem: they require a, b, and c to be default-constructible
> and move-assignable.
>
>
If they are in fact tuples/ties.


> Given the alternatives in the design space, returning a tuple and
> capturing it with 'auto' seems reasonable to me, aside from the syntactic
> inconvenience of accessing a tuple element. If the caller needs names for
> the fields, maybe returning a tuple with unnamed fields was a poor design
> choice, and returning a struct would be a better option?
>
> --
>
>

--

---
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.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposals/?hl=en.



--089e012281b43b1cfe04dc67fb85
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><br><div class=3D"gmail_extra"><br><br><div class=3D"gmail=
_quote">On Fri, May 10, 2013 at 2:48 PM, Richard Smith <span dir=3D"ltr">&l=
t;<a href=3D"mailto:richard@metafoo.co.uk" target=3D"_blank">richard@metafo=
o.co.uk</a>&gt;</span> wrote:<br>

<blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1p=
x #ccc solid;padding-left:1ex"><br><div><div><br></div></div><div class=3D"=
gmail_quote"><div>An expression starting with &#39;{&#39; is certainly prob=
lematic. The problem here isn&#39;t so much how to parse it (that actually =
turns out to be tractable with basically no overhead and no extra lookahead=
) but more that it seriously harms diagnostics and error recovery in some i=
mportant cases. There are some genuinely ambiguous cases, too, if we allow =
the general form:</div>


<div><br></div><div>=A0 {} + x; // empty compound-statement followed by una=
ry operator, or binary operator with empty braced-init-list on LHS?</div><d=
iv><br></div></div></blockquote><div><br></div><div>I&#39;d like to pretend=
 that is:<br>

<br>=A0=A0 std::tuple&lt;&gt;() + x;<br><br>=A0<br></div><blockquote class=
=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1px #ccc solid;padd=
ing-left:1ex"><div class=3D"gmail_quote"><div></div><div>Using parens, as t=
he original proposal suggests, may avoid this particular problem, but I str=
ongly suspect there will still be ambiguities.</div>


<div><br></div></div></blockquote><div><br></div><div>We could always use s=
ome new parens.=A0 ie {: a, b, c :}=A0 or happy faces or other emoticons.<b=
r>=A0<br></div><blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex=
;border-left:1px #ccc solid;padding-left:1ex">

<div class=3D"gmail_quote"><div></div><div><br></div><div>I&#39;ve been exp=
erimenting with a different approach to this problem: allow a restricted fo=
rm of simple-declaration as an lvalue expression, then:</div><div><br></div=
>

<div>=A0 std::tie(int a, int b, const char *c) =3D f();</div>
<div><br></div><div>This also lessens the need to use tuples at all, since =
you can write out-parameters like this:</div><div><br></div><div>=A0 f(int =
a, int b, const char *c);</div><div><br></div></div></blockquote><div><br>

</div><div>That doesn&#39;t look very out-ish to me at first glance.<br><br=
>=A0<br></div><blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;=
border-left:1px #ccc solid;padding-left:1ex"><div class=3D"gmail_quote"><di=
v></div>

<div>This still has some harmful impact on error recovery (the above could =
be a declaration of &#39;f&#39; missing a return type, for instance), and i=
t requires restricting the declarator forms to avoid declaration/expression=
 ambiguity for cases like &#39;f(int(a))&#39;.</div>


<div><br></div><div>Both this and the &quot;{ a, b, c } =3D &quot; form hav=
e an additional (potentially significant) problem: they require a, b, and c=
 to be default-constructible and move-assignable.</div><div><br></div></div=
>

</blockquote><br></div><div class=3D"gmail_quote">If they are in fact tuple=
s/ties.<br><br></div><div class=3D"gmail_quote"><blockquote class=3D"gmail_=
quote" style=3D"margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1=
ex">

<div class=3D"gmail_quote"><div></div><div>
<br></div><div>Given the alternatives in the design space, returning a tupl=
e and capturing it with &#39;auto&#39; seems reasonable to me, aside from t=
he syntactic inconvenience of accessing a tuple element. If the caller need=
s names for the fields, maybe returning a tuple with unnamed fields was a p=
oor design choice, and returning a struct would be a better option?</div>


</div><div><div>

<p></p>

-- <br>=A0
<br></div></div></blockquote></div></div></div>

<p></p>

-- <br />
&nbsp;<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 std-proposals+unsubscribe@isocpp.org.<br />
To post to this group, send email to std-proposals@isocpp.org.<br />
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/?hl=3Den">http://groups.google.com/a/isocpp.org/group/std-pro=
posals/?hl=3Den</a>.<br />
&nbsp;<br />
&nbsp;<br />

--089e012281b43b1cfe04dc67fb85--

.


Author: enisbayramoglu@gmail.com
Date: Fri, 12 Jul 2013 05:04:16 -0700 (PDT)
Raw View
------=_Part_48_16096609.1373630656370
Content-Type: text/plain; charset=ISO-8859-1

I usually don't have a problem with writing:

int a; double b;
tie(a,b) = f();

And I really like using tuples this way, but (to me) there are two cases
where the tuples as an alternative to multiple return values. (1) when the
types in the tuple are hard to write, (2) at the beginning of a "for" loop:

(1)
decltype(f().first) a; decltype(f().second b; // and possibly the list goes
on
tie(a,b) = f();

(2)
int a; double b; // Note that these variables are outside the scope of the
for loop, so that's not the same thing
for(tie(a,b)=f(); a<b;a++) ...

The alternative to (2) to avoid a and b from spilling over to the enclosing
scope it the following:

{
   int a; double b;
   for(tie(a,b)=f(); a<b;a++) {
      // Do stuff
   }
}

Which is rather ugly.

--

---
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.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposals/.



------=_Part_48_16096609.1373630656370
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable

I usually don't have a problem with writing:<div><br></div><div>int a; doub=
le b;</div><div>tie(a,b) =3D f();</div><div><br></div><div>And I really lik=
e using tuples this way, but (to me) there are two cases where the tuples a=
s an alternative to multiple return values. (1) when the types in the tuple=
 are hard to write, (2) at the beginning of a "for" loop:<br><br>(1)</div><=
div>decltype(f().first) a; decltype(f().second b; // and possibly the list =
goes on</div><div>tie(a,b) =3D f();&nbsp;</div><div><br></div><div>(2)</div=
><div>int a; double b; // Note that these variables are outside the scope o=
f the for loop, so that's not the same thing</div><div>for(tie(a,b)=3Df(); =
a&lt;b;a++) ...&nbsp;</div><div><br></div><div>The alternative to (2) to av=
oid a and b from spilling over to the enclosing scope it the following:<br>=
</div><div><br></div><div>{</div><div><div>&nbsp; &nbsp;int a; double b;&nb=
sp;</div><div>&nbsp; &nbsp;for(tie(a,b)=3Df(); a&lt;b;a++) {</div></div><di=
v>&nbsp; &nbsp; &nbsp; // Do stuff</div><div>&nbsp; &nbsp;}</div><div>}</di=
v><div><br></div><div>Which is rather ugly.</div>

<p></p>

-- <br />
&nbsp;<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 std-proposals+unsubscribe@isocpp.org.<br />
To post to this group, send email to std-proposals@isocpp.org.<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 />
&nbsp;<br />
&nbsp;<br />

------=_Part_48_16096609.1373630656370--

.