Topic: Tuple syntax overhaul
Author: Antonio Perez <antonio@perezexcelsior.com>
Date: Tue, 9 Aug 2016 16:34:04 -0700 (PDT)
Raw View
------=_Part_439_306075160.1470785644331
Content-Type: multipart/alternative;
boundary="----=_Part_440_1085548252.1470785644331"
------=_Part_440_1085548252.1470785644331
Content-Type: text/plain; charset=UTF-8
Tuples have the capacity to be an important and versatile tool for
programming in C++, however they are currently limited by verbose and
sometimes confusing syntax. I'd like to propose that tuples are built
directly into the language, rather than being a library feature, and I'd
also like to propose some syntax for tuples:
using namespace std;
int a = 5;
string s = "Hello, world";
//initialization:
[int, string] FirstTuple(a, s);
//Or
[auto, auto] SecondTuple(a, s);
//Or
auto ThirdTuple = [a, s];
//tuple::0 accesses the first element in the tuple
//tuple::1 accesses the second element in the tuple
//tuple::2 accesses the third element in the tuple (if there is one), and
so on
FirstTuple.0 = 10//FirstTuple.0 is the first item in FirstTuple
FirstTuple.1 = "Hi!";//FirstTuple.1 is the second item in FirstTuple
cout << FirstTuple.0 << endl; //Prints 10
cout << FirstTuple.1 << endl; //Prints "Hi!"
//Annonymous tuple;
[double x, double y] = [ 1.0, 3.7 ];
//Also a valid initialization:
[double x2, double y2] = { 1.0, 3.7 };
//Same thing:
[auto x3, auto y3] = { 1.0, 3.7 };
cout << x << endl; //Prints 1
cout << y << endl; //Prints 3.7
//Regular tuple with named fields
[double x, double y] MyTup = [0.3, 0.4];
cout << MyTup.x << endl;//Prints 0.3
cout << MyTup.0 << endl;//Prints 0.3
cout << MyTup.y << endl;//Prints 0.4
cout << MyTup.1 << endl;//Prints 0.4
int foo = 1;
int bar = 2;
int blarg = 3;
auto tup3 = [foo, bar, blarg];//Creates tuple of type [int, int, int]
auto tup4 = [foo&, bar, blarg&];//Creates tuple of type [int&, int, int&]
int &foo_ref = foo;
auto tup5 = [foo_ref]; //Creates tuple of type [int&]
auto tup6 = [foo_ref, bar, blarg];//Creates a tuple of type [int&, int, int]
const int zero = 0;
const int one = 1;
const int two = 2;
auto AnotherTuple = [1, "two", 3];//Creates a tuple of type [int, const
char*, int]
cout << AnotherTuple.zero << endl;//Compile time error - zero is not a
member of AnotherTuple
//To access a member of a tuple with a compile-time constant, wrap it with
parenthesis
cout << AnotherTuple.(zero) << endl;//Prints 1
cout << AnotherTuple.(one) << endl;//Prints "two"
cout << AnotherTuple.(two) << endl;//Prints 3
//Adding three dots at the end of a tuple expands it. For example:
[int, int, int] IntTriplet = [1, 10, 100];//Creates a tuple of type [int,
int, int]
auto Sum = [](int a, int b, int c) {return a + b + c; };
cout << Sum(IntTriplet...) << endl;//Expands the tuple; prints 111
//Example implementation of std::tie and std::make_tuple under the new
syntax:
namespace std {
template<typename... T> [T&...] tie(T&... inputs) {
return [inputs...];
}
template<typename... T>[T...] make_tuple(T&&... inputs) {
return [T(inputs)...];
}
}
An example of a language with similar syntax and built-in tuples is Apple's
language Swift
--
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/f702545e-bd19-449e-a698-672f34595b95%40isocpp.org.
------=_Part_440_1085548252.1470785644331
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr">Tuples have the capacity to be an important and versatile =
tool for programming in C++, however they are currently limited by verbose =
and sometimes confusing syntax. I'd like to propose that tuples are bui=
lt directly into the language, rather than being a library feature, and I&#=
39;d also like to propose some syntax for tuples:<div><br></div><div><div c=
lass=3D"prettyprint" style=3D"border: 1px solid rgb(187, 187, 187); word-wr=
ap: break-word; background-color: rgb(250, 250, 250);"><code class=3D"prett=
yprint"><div class=3D"subprettyprint"><font color=3D"#000088"><div class=3D=
"subprettyprint">using namespace std;</div><div class=3D"subprettyprint">in=
t a =3D 5;</div><div class=3D"subprettyprint">string s =3D "Hello, wor=
ld";</div><div class=3D"subprettyprint">//initialization:=C2=A0</div><=
div class=3D"subprettyprint">[int, string] FirstTuple(a, s);</div><div clas=
s=3D"subprettyprint">//Or</div><div class=3D"subprettyprint">[auto, auto] S=
econdTuple(a, s);</div><div class=3D"subprettyprint">//Or</div><div class=
=3D"subprettyprint">auto ThirdTuple =3D [a, s];</div><div class=3D"subprett=
yprint"><br></div><div class=3D"subprettyprint">//tuple::0 accesses the fir=
st element in the tuple</div><div class=3D"subprettyprint">//tuple::1 acces=
ses the second element in the tuple</div><div class=3D"subprettyprint">//tu=
ple::2 accesses the third element in the tuple (if there is one), and so on=
</div><div class=3D"subprettyprint">FirstTuple.0 =3D 10//FirstTuple.0 is th=
e first item in FirstTuple</div><div class=3D"subprettyprint">FirstTuple.1 =
=3D "Hi!";//FirstTuple.1 is the second item in FirstTuple</div><d=
iv class=3D"subprettyprint"><br></div><div class=3D"subprettyprint">cout &l=
t;< FirstTuple.0 << endl; //Prints 10</div><div class=3D"subpretty=
print"><br></div><div class=3D"subprettyprint">cout << FirstTuple.1 &=
lt;< endl; //Prints "Hi!"</div><div class=3D"subprettyprint"><=
br></div><div class=3D"subprettyprint">//Annonymous tuple;</div><div class=
=3D"subprettyprint">[double x, double y] =3D [ 1.0, 3.7 ];</div><div class=
=3D"subprettyprint">//Also a valid initialization:=C2=A0</div><div class=3D=
"subprettyprint">[double x2, double y2] =3D { 1.0, 3.7 };</div><div class=
=3D"subprettyprint">//Same thing:=C2=A0</div><div class=3D"subprettyprint">=
[auto x3, auto y3] =3D { 1.0, 3.7 };</div><div class=3D"subprettyprint"><br=
></div><div class=3D"subprettyprint">cout << x << endl; //Print=
s 1</div><div class=3D"subprettyprint">cout << y << endl; //Pri=
nts 3.7</div><div class=3D"subprettyprint"><br></div><div class=3D"subprett=
yprint">//Regular tuple with named fields</div><div class=3D"subprettyprint=
">[double x, double y] MyTup =3D [0.3, 0.4];</div><div class=3D"subprettypr=
int">cout << MyTup.x << endl;//Prints 0.3</div><div class=3D"su=
bprettyprint">cout << MyTup.0 << endl;//Prints 0.3</div><div cl=
ass=3D"subprettyprint">cout << MyTup.y << endl;//Prints 0.4</di=
v><div class=3D"subprettyprint">cout << MyTup.1 << endl;//Print=
s 0.4</div><div class=3D"subprettyprint"><br></div><div class=3D"subprettyp=
rint">int foo =3D 1;</div><div class=3D"subprettyprint">int bar =3D 2;</div=
><div class=3D"subprettyprint">int blarg =3D 3;</div><div class=3D"subprett=
yprint">auto tup3 =3D [foo, bar, blarg];//Creates tuple of type [int, int, =
int]</div><div class=3D"subprettyprint">auto tup4 =3D [foo&, bar, blarg=
&];//Creates tuple of type [int&, int, int&]</div><div class=3D=
"subprettyprint"><br></div><div class=3D"subprettyprint">int &foo_ref =
=3D foo;</div><div class=3D"subprettyprint">auto tup5 =3D [foo_ref]; //Crea=
tes tuple of type [int&]</div><div class=3D"subprettyprint">auto tup6 =
=3D [foo_ref, bar, blarg];//Creates a tuple of type [int&, int, int]</d=
iv><div class=3D"subprettyprint"><br></div><div class=3D"subprettyprint">co=
nst int zero =3D 0;</div><div class=3D"subprettyprint">const int one =3D 1;=
</div><div class=3D"subprettyprint">const int two =3D 2;</div><div class=3D=
"subprettyprint">auto AnotherTuple =3D [1, "two", 3];//Creates a =
tuple of type [int, const char*, int]</div><div class=3D"subprettyprint">co=
ut << AnotherTuple.zero << endl;//Compile time error - zero is =
not a member of AnotherTuple</div><div class=3D"subprettyprint">//To access=
a member of a tuple with a compile-time constant, wrap it with parenthesis=
</div><div class=3D"subprettyprint"><br></div><div class=3D"subprettyprint"=
>cout << AnotherTuple.(zero) << endl;//Prints 1</div><div class=
=3D"subprettyprint">cout << AnotherTuple.(one) << endl;//Prints=
"two"</div><div class=3D"subprettyprint">cout << AnotherTu=
ple.(two) << endl;//Prints 3</div><div class=3D"subprettyprint"><br><=
/div><div class=3D"subprettyprint">//Adding three dots at the end of a tupl=
e expands it. For example:</div><div class=3D"subprettyprint">[int, int, in=
t] IntTriplet =3D [1, 10, 100];//Creates a tuple of type [int, int, int]</d=
iv><div class=3D"subprettyprint">auto Sum =3D [](int a, int b, int c) {retu=
rn a + b + c; };</div><div class=3D"subprettyprint">cout << Sum(IntTr=
iplet...) << endl;//Expands the tuple; prints 111</div><div class=3D"=
subprettyprint"><br></div><div class=3D"subprettyprint">//Example implement=
ation of std::tie and std::make_tuple under the new syntax:</div><div class=
=3D"subprettyprint">namespace std {</div><div class=3D"subprettyprint"><spa=
n class=3D"Apple-tab-span" style=3D"white-space:pre"> </span>template<ty=
pename... T> [T&...] tie(T&... inputs) {</div><div class=3D"subp=
rettyprint"><span class=3D"Apple-tab-span" style=3D"white-space:pre"> </sp=
an>return [inputs...];</div><div class=3D"subprettyprint"><span class=3D"Ap=
ple-tab-span" style=3D"white-space:pre"> </span>}</div><div class=3D"subpre=
ttyprint"><span class=3D"Apple-tab-span" style=3D"white-space:pre"> </span>=
template<typename... T>[T...] make_tuple(T&&... inputs) {</di=
v><div class=3D"subprettyprint"><span class=3D"Apple-tab-span" style=3D"whi=
te-space:pre"> </span>return [T(inputs)...];</div><div class=3D"subprettyp=
rint"><span class=3D"Apple-tab-span" style=3D"white-space:pre"> </span>}</d=
iv><div class=3D"subprettyprint">}</div></font></div></code></div><br>An ex=
ample of a language with similar syntax and built-in tuples is Apple's =
language Swift</div></div>
<p></p>
-- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals" 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/f702545e-bd19-449e-a698-672f34595b95%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/f702545e-bd19-449e-a698-672f34595b95=
%40isocpp.org</a>.<br />
------=_Part_440_1085548252.1470785644331--
------=_Part_439_306075160.1470785644331--
.
Author: HarD Gamer <rodrigojose690@gmail.com>
Date: Tue, 9 Aug 2016 16:55:45 -0700 (PDT)
Raw View
------=_Part_1982_414989891.1470786945128
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
Em ter=C3=A7a-feira, 9 de agosto de 2016 20:34:04 UTC-3, Antonio Perez esc=
reveu:
> Tuples have the capacity to be an important and versatile tool for progra=
mming in C++, however they are currently limited by verbose and sometimes c=
onfusing syntax. I'd like to propose that tuples are built directly into th=
e language, rather than being a library feature, and I'd also like to propo=
se some syntax for tuples:
>=20
>=20
>=20
>=20
>=20
> using namespace std;
> int a =3D 5;
> string s =3D "Hello, world";
> //initialization:=C2=A0
> [int, string] FirstTuple(a, s);
> //Or
> [auto, auto] SecondTuple(a, s);
> //Or
> auto ThirdTuple =3D [a, s];
>=20
>=20
> //tuple::0 accesses the first element in the tuple
> //tuple::1 accesses the second element in the tuple
> //tuple::2 accesses the third element in the tuple (if there is one), and=
so on
> FirstTuple.0 =3D 10//FirstTuple.0 is the first item in FirstTuple
> FirstTuple.1 =3D "Hi!";//FirstTuple.1 is the second item in FirstTuple
>=20
>=20
> cout << FirstTuple.0 << endl; //Prints 10
>=20
>=20
> cout << FirstTuple.1 << endl; //Prints "Hi!"
>=20
>=20
> //Annonymous tuple;
> [double x, double y] =3D [ 1.0, 3.7 ];
> //Also a valid initialization:=C2=A0
> [double x2, double y2] =3D { 1.0, 3.7 };
> //Same thing:=C2=A0
> [auto x3, auto y3] =3D { 1.0, 3.7 };
>=20
>=20
> cout << x << endl; //Prints 1
> cout << y << endl; //Prints 3.7
>=20
>=20
> //Regular tuple with named fields
> [double x, double y] MyTup =3D [0.3, 0.4];
> cout << MyTup.x << endl;//Prints 0.3
> cout << MyTup.0 << endl;//Prints 0.3
> cout << MyTup.y << endl;//Prints 0.4
> cout << MyTup.1 << endl;//Prints 0.4
>=20
>=20
> int foo =3D 1;
> int bar =3D 2;
> int blarg =3D 3;
> auto tup3 =3D [foo, bar, blarg];//Creates tuple of type [int, int, int]
> auto tup4 =3D [foo&, bar, blarg&];//Creates tuple of type [int&, int, int=
&]
>=20
>=20
> int &foo_ref =3D foo;
> auto tup5 =3D [foo_ref]; //Creates tuple of type [int&]
> auto tup6 =3D [foo_ref, bar, blarg];//Creates a tuple of type [int&, int,=
int]
>=20
>=20
> const int zero =3D 0;
> const int one =3D 1;
> const int two =3D 2;
> auto AnotherTuple =3D [1, "two", 3];//Creates a tuple of type [int, const=
char*, int]
> cout << AnotherTuple.zero << endl;//Compile time error - zero is not a me=
mber of AnotherTuple
> //To access a member of a tuple with a compile-time constant, wrap it wit=
h parenthesis
>=20
>=20
> cout << AnotherTuple.(zero) << endl;//Prints 1
> cout << AnotherTuple.(one) << endl;//Prints "two"
> cout << AnotherTuple.(two) << endl;//Prints 3
>=20
>=20
> //Adding three dots at the end of a tuple expands it. For example:
> [int, int, int] IntTriplet =3D [1, 10, 100];//Creates a tuple of type [in=
t, int, int]
> auto Sum =3D [](int a, int b, int c) {return a + b + c; };
> cout << Sum(IntTriplet...) << endl;//Expands the tuple; prints 111
>=20
>=20
> //Example implementation of std::tie and std::make_tuple under the new sy=
ntax:
> namespace std {
> template<typename... T> [T&...] tie(T&... inputs) {
> return [inputs...];
> }
> template<typename... T>[T...] make_tuple(T&&... inputs) {
> return [T(inputs)...];
> }
> }
> An example of a language with similar syntax and built-in t
THAT IS SOMETHING LIKE THIS IN C++17 sintax. check here isocpp.com
--=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.
To view this discussion on the web visit https://groups.google.com/a/isocpp=
..org/d/msgid/std-proposals/02ef4ab0-251d-4613-8f07-877855f9a86c%40isocpp.or=
g.
------=_Part_1982_414989891.1470786945128--
.
Author: "D. B." <db0451@gmail.com>
Date: Wed, 10 Aug 2016 08:01:52 +0100
Raw View
--001a114b3dac65f8100539b239cb
Content-Type: text/plain; charset=UTF-8
But AFAICT the Committee try avoid adding core-langauage features that can
be adequately served by library usage. Also, the tuple syntax is now
heavily established and entrenched. How would one keep that version around
while adding a new one, and ensure both were synced up?
Rather, what would be best would be to make parts of tuples into language
built-in syntax, which would then transform to particular calls to the
existing stdlib class and/or pieces of more literal but more verbose
syntax. Like std::initializer_list and range-for respectively. And doing it
this way might mean the benefits could be extended to other types, not just
tuples.
Lastly, do you think your proposed grammar would be unambiguous enough to
use? Lambdas exist, as do the following...
On Wed, Aug 10, 2016 at 12:55 AM, HarD Gamer <rodrigojose690@gmail.com>
wrote:
> THAT IS SOMETHING LIKE THIS IN C++17 sintax. check here isocpp.com
DON'T SHOUT. And if you're going to refer people to something, at least
provide a proper link or something you can use.
You're probably talking about structured binding, but that does the
opposite thing: given [a, b, c] = RHS, it unpacks some struct or tuple RHS
into the individual variables specified on the left.
Also, it seems that what I alluded to above about making certain bits of
syntax language built-ins already applies here, since [structured, binding]
knows what to do with a tuple on the RHS, despite that being a template
class.
--
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/CACGiwhEhVkQJxNtxaDKG5v8fG7%2BY4K70nY7fSBAGUg4csK7Nbg%40mail.gmail.com.
--001a114b3dac65f8100539b239cb
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr"><div class=3D"gmail_extra">But AFAICT the Committee try av=
oid adding core-langauage features that can be adequately served by library=
usage. Also, the tuple syntax is now heavily established and entrenched. H=
ow would one keep that version around while adding a new one, and ensure bo=
th were synced up?<br><br></div><div class=3D"gmail_extra">Rather, what wou=
ld be best would be to make parts of tuples into language built-in syntax, =
which would then transform to particular calls to the existing stdlib class=
and/or pieces of more literal but more verbose syntax. Like std::initializ=
er_list and range-for respectively. And doing it this way might mean the be=
nefits could be extended to other types, not just tuples.<br><br></div><div=
class=3D"gmail_extra">Lastly, do you think your proposed grammar would be =
unambiguous enough to use? Lambdas exist, as do the following...<br></div><=
div class=3D"gmail_extra"><br><div class=3D"gmail_quote">On Wed, Aug 10, 20=
16 at 12:55 AM, HarD Gamer <span dir=3D"ltr"><<a href=3D"mailto:rodrigoj=
ose690@gmail.com" target=3D"_blank">rodrigojose690@gmail.com</a>></span>=
wrote:<br><blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;bor=
der-left:1px #ccc solid;padding-left:1ex"><div class=3D"HOEnZb"><div class=
=3D"h5">
</div></div>THAT IS SOMETHING LIKE THIS IN C++17 sintax. check here <a href=
=3D"http://isocpp.com" rel=3D"noreferrer" target=3D"_blank">isocpp.com</a><=
/blockquote><div>DON'T SHOUT. And if you're going to refer people t=
o something, at least provide a proper link or something you can use.<br><b=
r>You're probably talking about structured binding, but that does the o=
pposite thing: given [a, b, c] =3D RHS, it unpacks some struct or tuple RHS=
into the individual variables specified on the left.<br><br></div><div>Als=
o, it seems that what I alluded to above about making certain bits of synta=
x language built-ins already applies here, since [structured, binding] know=
s what to do with a tuple on the RHS, despite that being a template class.<=
br><br></div></div></div></div>
<p></p>
-- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals" 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/CACGiwhEhVkQJxNtxaDKG5v8fG7%2BY4K70nY=
7fSBAGUg4csK7Nbg%40mail.gmail.com?utm_medium=3Demail&utm_source=3Dfooter">h=
ttps://groups.google.com/a/isocpp.org/d/msgid/std-proposals/CACGiwhEhVkQJxN=
txaDKG5v8fG7%2BY4K70nY7fSBAGUg4csK7Nbg%40mail.gmail.com</a>.<br />
--001a114b3dac65f8100539b239cb--
.
Author: "D. B." <db0451@gmail.com>
Date: Wed, 10 Aug 2016 10:04:56 +0100
Raw View
--001a1142c65678f3d90539b3f14a
Content-Type: text/plain; charset=UTF-8
....that sounded a bit self-contradictory. What I meant by not adding
core-language features was to keep std::tuple as a template class, rather
than making it into a 1st-class type. The only new language features would
be shortcut syntaxes that would invoke appropriate operations on
std::tuple, like we already have for initializer_list and with range-for.
So that's a lot less intrusive to the core language than the idea of making
tuple a 1st-class type.
What might be useful is if you show an example of code that is currently
highly unwieldy with tuples, tell us what the problem is, and show how your
proposal - which would probably need changes to the chosen punctuation etc
- would solve it. As it is, I'm finding it hard to see enough of a problem
to make changes to the language, but then I probably just don't use tuples
as much as other people, so it's possible I'm missing the point.
--
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/CACGiwhGrH8OCHN-6J3WKPLvtPjd8kuP-ywuE%3DSBBrTLExthrLA%40mail.gmail.com.
--001a1142c65678f3d90539b3f14a
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr"><div>...that sounded a bit self-contradictory. What I mean=
t by not adding core-language features was to keep std::tuple as a template=
class, rather than making it into a 1st-class type. The only new language =
features would be shortcut syntaxes that would invoke appropriate operation=
s on std::tuple, like we already have for initializer_list and with range-f=
or. So that's a lot less intrusive to the core language than the idea o=
f making tuple a 1st-class type.<br><br></div>What might be useful is if yo=
u show an example of code that is currently highly unwieldy with tuples, te=
ll us what the problem is, and show how your proposal - which would probabl=
y need changes to the chosen punctuation etc - would solve it. As it is, I&=
#39;m finding it hard to see enough of a problem to make changes to the lan=
guage, but then I probably just don't use tuples as much as other peopl=
e, so it's possible I'm missing the point.<br></div>
<p></p>
-- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals" 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/CACGiwhGrH8OCHN-6J3WKPLvtPjd8kuP-ywuE=
%3DSBBrTLExthrLA%40mail.gmail.com?utm_medium=3Demail&utm_source=3Dfooter">h=
ttps://groups.google.com/a/isocpp.org/d/msgid/std-proposals/CACGiwhGrH8OCHN=
-6J3WKPLvtPjd8kuP-ywuE%3DSBBrTLExthrLA%40mail.gmail.com</a>.<br />
--001a1142c65678f3d90539b3f14a--
.
Author: "Vicente J. Botet Escriba" <vicente.botet@wanadoo.fr>
Date: Wed, 10 Aug 2016 19:25:11 +0200
Raw View
Le 10/08/2016 =C3=A0 11:04, D. B. a =C3=A9crit :
> ...that sounded a bit self-contradictory. What I meant by not adding=20
> core-language features was to keep std::tuple as a template class,=20
> rather than making it into a 1st-class type. The only new language=20
> features would be shortcut syntaxes that would invoke appropriate=20
> operations on std::tuple, like we already have for initializer_list=20
> and with range-for. So that's a lot less intrusive to the core=20
> language than the idea of making tuple a 1st-class type.
>
> What might be useful is if you show an example of code that is=20
> currently highly unwieldy with tuples, tell us what the problem is,=20
> and show how your proposal - which would probably need changes to the=20
> chosen punctuation etc - would solve it. As it is, I'm finding it hard=20
> to see enough of a problem to make changes to the language, but then I=20
> probably just don't use tuples as much as other people, so it's=20
> possible I'm missing the point.
p0341r0 should be of interest in this thread.
http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2016/p0341r0.html
Vicente
--=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.
To view this discussion on the web visit https://groups.google.com/a/isocpp=
..org/d/msgid/std-proposals/adb5c70c-6a0e-4921-33b6-ae125437efd0%40wanadoo.f=
r.
.
Author: Sean Middleditch <sean.middleditch@gmail.com>
Date: Wed, 10 Aug 2016 22:40:22 -0700 (PDT)
Raw View
------=_Part_214_392932973.1470894022247
Content-Type: multipart/alternative;
boundary="----=_Part_215_392824245.1470894022258"
------=_Part_215_392824245.1470894022258
Content-Type: text/plain; charset=UTF-8
On Wednesday, August 10, 2016 at 12:01:55 AM UTC-7, D. B. wrote:
>
> But AFAICT the Committee try avoid adding core-langauage features that can
> be adequately served by library usage. Also, the tuple syntax is now
> heavily established and entrenched. How would one keep that version around
> while adding a new one, and ensure both were synced up?
>
Just to be fair: consider std::bind vs lambdas.
Now, lambdas do considerably more than std::bind was even capable of
(lambdas can contain whole statements/blocks), which is where the big
value-add comes from. The ergonomics definitely played a part in getting
them accepted, though. Just replacing std::tuple with a
slightly-easier-to-use language feature is of likely low value.
If there is something particular that a language feature can do that a
library cannot then there's a good case for a language feature. Otherwise,
the syntactical improvements have to _really_ make a difference. In this
case, the biggest improvement in usage I see are the typed additions to the
destructuring feature, which don't really have anything to do with tuples.
:)
There are those tie/make_tuple definitions, and those seems promising. If
you can prove out that your proposal really does make library-grade
facilities that easy (it rarely is) and can show off some more use cases
that are difficult to pull off with template today, that also might make a
strong case for language tuples.
>
> Rather, what would be best would be to make parts of tuples into language
> built-in syntax, which would then transform to particular calls to the
> existing stdlib class and/or pieces of more literal but more verbose
> syntax. Like std::initializer_list and range-for respectively. And doing it
> this way might mean the benefits could be extended to other types, not just
> tuples.
>
> Lastly, do you think your proposed grammar would be unambiguous enough to
> use? Lambdas exist, as do the following...
>
> On Wed, Aug 10, 2016 at 12:55 AM, HarD Gamer <rodrigo...@gmail.com
> <javascript:>> wrote:
>
>> THAT IS SOMETHING LIKE THIS IN C++17 sintax. check here isocpp.com
>
> DON'T SHOUT. And if you're going to refer people to something, at least
> provide a proper link or something you can use.
>
> You're probably talking about structured binding, but that does the
> opposite thing: given [a, b, c] = RHS, it unpacks some struct or tuple RHS
> into the individual variables specified on the left.
>
> Also, it seems that what I alluded to above about making certain bits of
> syntax language built-ins already applies here, since [structured, binding]
> knows what to do with a tuple on the RHS, despite that being a template
> class.
>
>
--
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/c1dc53fb-e383-4a58-bab7-60d00e5c7e92%40isocpp.org.
------=_Part_215_392824245.1470894022258
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr">On Wednesday, August 10, 2016 at 12:01:55 AM UTC-7, D. B. =
wrote:<blockquote class=3D"gmail_quote" style=3D"margin: 0;margin-left: 0.8=
ex;border-left: 1px #ccc solid;padding-left: 1ex;"><div dir=3D"ltr"><div>Bu=
t AFAICT the Committee try avoid adding core-langauage features that can be=
adequately served by library usage. Also, the tuple syntax is now heavily =
established and entrenched. How would one keep that version around while ad=
ding a new one, and ensure both were synced up?<br></div></div></blockquote=
><div><br></div><div>Just to be fair: consider std::bind vs lambdas.</div><=
div><br></div><div>Now, lambdas do considerably more than std::bind was eve=
n capable of (lambdas can contain whole statements/blocks), which is where =
the big value-add comes from. The ergonomics definitely played a part in ge=
tting them accepted, though. Just replacing std::tuple with a slightly-easi=
er-to-use language feature is of likely low value.</div><div><br></div><div=
>If there is something particular that a language feature can do that a lib=
rary cannot then there's a good case for a language feature. Otherwise,=
the syntactical improvements have to _really_ make a difference. In this c=
ase, the biggest improvement in usage I see are the typed additions to the =
destructuring feature, which don't really have anything to do with tupl=
es. :)</div><div><br></div><div>There are those tie/make_tuple definitions,=
and those seems promising. If you can prove out that your proposal really =
does make library-grade facilities that easy (it rarely is) and can show of=
f some more use cases that are difficult to pull off with template today, t=
hat also might make a strong case for language tuples.</div><div>=C2=A0</di=
v><blockquote class=3D"gmail_quote" style=3D"margin: 0;margin-left: 0.8ex;b=
order-left: 1px #ccc solid;padding-left: 1ex;"><div dir=3D"ltr"><div><br></=
div><div>Rather, what would be best would be to make parts of tuples into l=
anguage built-in syntax, which would then transform to particular calls to =
the existing stdlib class and/or pieces of more literal but more verbose sy=
ntax. Like std::initializer_list and range-for respectively. And doing it t=
his way might mean the benefits could be extended to other types, not just =
tuples.<br><br></div><div>Lastly, do you think your proposed grammar would =
be unambiguous enough to use? Lambdas exist, as do the following...<br></di=
v><div><br><div class=3D"gmail_quote">On Wed, Aug 10, 2016 at 12:55 AM, Har=
D Gamer <span dir=3D"ltr"><<a href=3D"javascript:" target=3D"_blank" gdf=
-obfuscated-mailto=3D"c0cwaJZXCQAJ" rel=3D"nofollow" onmousedown=3D"this.hr=
ef=3D'javascript:';return true;" onclick=3D"this.href=3D'javasc=
ript:';return true;">rodrigo...@gmail.com</a>></span> wrote:<br><blo=
ckquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1px #c=
cc solid;padding-left:1ex"><div><div>
</div></div>THAT IS SOMETHING LIKE THIS IN C++17 sintax. check here <a href=
=3D"http://isocpp.com" rel=3D"nofollow" target=3D"_blank" onmousedown=3D"th=
is.href=3D'http://www.google.com/url?q\x3dhttp%3A%2F%2Fisocpp.com\x26sa=
\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNEswuhLJEnyR-HTWkdm_OX8emrLYQ';return=
true;" onclick=3D"this.href=3D'http://www.google.com/url?q\x3dhttp%3A%=
2F%2Fisocpp.com\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNEswuhLJEnyR-HTWkdm_=
OX8emrLYQ';return true;">isocpp.com</a></blockquote><div>DON'T SHOU=
T. And if you're going to refer people to something, at least provide a=
proper link or something you can use.<br><br>You're probably talking a=
bout structured binding, but that does the opposite thing: given [a, b, c] =
=3D RHS, it unpacks some struct or tuple RHS into the individual variables =
specified on the left.<br><br></div><div>Also, it seems that what I alluded=
to above about making certain bits of syntax language built-ins already ap=
plies here, since [structured, binding] knows what to do with a tuple on th=
e RHS, despite that being a template class.<br><br></div></div></div></div>
</blockquote></div>
<p></p>
-- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals" 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/c1dc53fb-e383-4a58-bab7-60d00e5c7e92%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/c1dc53fb-e383-4a58-bab7-60d00e5c7e92=
%40isocpp.org</a>.<br />
------=_Part_215_392824245.1470894022258--
------=_Part_214_392932973.1470894022247--
.
Author: Matthew Woehlke <mwoehlke.floss@gmail.com>
Date: Wed, 10 Aug 2016 14:10:40 -0400
Raw View
On 2016-08-09 19:34, Antonio Perez wrote:
> //tuple::0 accesses the first element in the tuple
> //tuple::1 accesses the second element in the tuple
> //tuple::2 accesses the third element in the tuple (if there is one), and=
=20
> so on
> FirstTuple.0 =3D 10//FirstTuple.0 is the first item in FirstTuple
> FirstTuple.1 =3D "Hi!";//FirstTuple.1 is the second item in FirstTuple
I agree we should have a syntax for this, but it should work for any
tuple-like and ideally also for parameter packs.
> //Annonymous tuple;
> [double x, double y] =3D [ 1.0, 3.7 ];
Er... no. Use "structured binding"=C2=B9 for that; it will already do this
with the simplified first-class tuple value syntax.
(=C2=B9 *cough*assignment unpacking*cough*)
> //Also a valid initialization:=20
> [double x2, double y2] =3D { 1.0, 3.7 };
Likewise. In fact, this is an extension to S.B. to work on initializer
lists, which IIRC has already been suggested.
> //Regular tuple with named fields
> [double x, double y] MyTup =3D [0.3, 0.4];
> cout << MyTup.x << endl;//Prints 0.3
> cout << MyTup.0 << endl;//Prints 0.3
> cout << MyTup.y << endl;//Prints 0.4
> cout << MyTup.1 << endl;//Prints 0.4
Um... why?
struct { double x; double y; } MyTup =3D {0.3, 0.4};
I don't think we should extend tuples into struct territory.
> //Adding three dots at the end of a tuple expands it. For example:
Again, I want generalized unpacking for *any* tuple-like, not just
tuples (built-in or otherwise).
--=20
Matthew
--=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.
To view this discussion on the web visit https://groups.google.com/a/isocpp=
..org/d/msgid/std-proposals/nofqn0%24k7l%241%40blaine.gmane.org.
.