Topic: Unpacking syntax for tuples using auto
Author: leszek.swirski@gmail.com
Date: Thu, 27 Feb 2014 10:17:37 -0800 (PST)
Raw View
------=_Part_698_11223515.1393525057974
Content-Type: text/plain; charset=UTF-8
Currently, given a function that returns a tuple
std::tuple<int,double> foo() {
return std::make_tuple(1, 2.0);
}
one can access the returned values using std::tie
int a;
double b;
std::tie(a,b) = foo();
but then you have to know the return types. Alternatively, without
specifying types one can use std::get:
auto ret = foo();
auto&& a = std::get<0>(ret);
auto&& b = std::get<1>(ret);
but then you create a new variable and the whole thing seems unnecessarily
verbose. Neither of these solutions seems particularly clean to me.
Would it be possible to introduce a new syntax, which both declares the
tuple element variables using the correct type, and assigns to them?
Something like
auto (a,b) = foo();
which would define a and b as int and double, and assign to them the values
1 and 2.0, respectively. This would be roughly equivalent to the behaviour
of the second option above, but without the extra variable, and behaving
like a single expression-statement rather than several.
An interesting application would be tuple unpacking in ranged-for loops,
where one could write
for (auto(key,value) : get_map()) {
...
}
which would be roughly equivalent to
for (auto&& __temp : get_map()) {
auto&& key = std::get<0>(__temp );
auto&& value = std::get<1>(__temp );
...
}
Arguably this feature is just syntactic sugar, but this sort of tuple
unpacking is very common in other languages (cf. Python, clojure), and I
believe that it would decrease the verbosity (and increase the clarity) of
things like multiple return values, map iterators, zip iterators and other
similar constructions. Also, one could make the argument that this hides
types, but there seems to be an increasing trend towards type inference in
C++ (first auto, now auto return values), so I don't personally thing that
this is a problem.
What do people think?
--
---
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_698_11223515.1393525057974
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr"><div>Currently, given a function that returns a tuple</div=
><div><br></div><div><font face=3D"courier new, monospace"> st=
d::tuple<int,double> foo() {</font></div><div><font face=3D"courier n=
ew, monospace"> return std::make_tuple(1, 2.0);<=
/font></div><div><font face=3D"courier new, monospace"> }</fon=
t></div><div><font face=3D"courier new, monospace"><br></font></div><div>on=
e can access the returned values using <font face=3D"courier new, monospace=
">std::tie</font></div><div><font face=3D"courier new, monospace"><br></fon=
t></div><div><font face=3D"courier new, monospace"> int a;</fo=
nt></div><div><font face=3D"courier new, monospace"> double b;=
</font></div><div><font face=3D"courier new, monospace"> std::=
tie(a,b) =3D foo();</font></div><div><font face=3D"courier new, monospace">=
<br></font></div><div>but then you have to know the return types. Alternati=
vely, without specifying types one can use <font face=3D"courier new, monos=
pace">std::get</font>:</div><div><br></div><div><font face=3D"courier new, =
monospace"> auto ret =3D foo();</font></div><div><font face=3D=
"courier new, monospace"> auto&& a =3D std::get<0&g=
t;(ret);</font></div><div><font face=3D"courier new, monospace"> &nbs=
p; auto&& b =3D std::get<1>(ret);</font></div><div><font face=
=3D"courier new, monospace"><br></font></div><div>but then you create a new=
variable and the whole thing seems unnecessarily verbose. Neither of these=
solutions seems particularly clean to me.</div><div><br></div><div>Would i=
t be possible to introduce a new syntax, which both declares the tuple elem=
ent variables using the correct type, and assigns to them? Something like</=
div><div><br></div><div><span style=3D"font-family: 'courier new', monospac=
e;"> auto (a,b) =3D foo();</span><br></div><div><font face=3D"=
arial, sans-serif"><br></font></div><div><font face=3D"arial, sans-serif">w=
hich would define </font><font face=3D"courier new, monospace">a</font><fon=
t face=3D"arial, sans-serif"> and </font><font face=3D"courier new, monospa=
ce">b</font><font face=3D"arial, sans-serif"> as </font><font face=3D"=
courier new, monospace">int</font><font face=3D"arial, sans-serif"> an=
d </font><font face=3D"courier new, monospace">double</font><font face=3D"a=
rial, sans-serif">, and assign to them the values </font><font face=3D"cour=
ier new, monospace">1</font><font face=3D"arial, sans-serif"> and </fo=
nt><font face=3D"courier new, monospace">2.0</font><font face=3D"arial, san=
s-serif">, respectively. This would be roughly equivalent to the behaviour =
of the second option above, but without the extra variable, and behaving li=
ke a single expression-statement rather than several.</font></div><div><fon=
t face=3D"arial, sans-serif"><br></font></div><div><font face=3D"arial, san=
s-serif">An interesting application would be tuple unpacking in ranged-for =
loops, where one could write</font></div><div><span style=3D"color: rgb(0, =
0, 0);"><br></span></div><div><span style=3D"color: rgb(0, 0, 0);"><font fa=
ce=3D"courier new, monospace"> for (auto(key,value) : get_map(=
)) {</font></span></div><div><span style=3D"color: rgb(0, 0, 0);"><font fac=
e=3D"courier new, monospace"> ...</font></span><=
/div><div><span style=3D"color: rgb(0, 0, 0);"><font face=3D"courier new, m=
onospace"> }</font></span></div><div><span style=3D"color: rgb=
(0, 0, 0);"><font face=3D"arial, sans-serif"><br></font></span></div><div><=
font color=3D"#000000" face=3D"arial, sans-serif">which would be roughly eq=
uivalent to</font></div><div><br></div><div><span style=3D"color: rgb(0, 0,=
0);"><font face=3D"courier new, monospace"> for (auto&&am=
p; __temp : get_map()) {</font></span></div><div><font face=3D"courier new,=
monospace"> auto&& key =3D std::get<=
0>(</font><span style=3D"color: rgb(0, 0, 0); font-family: 'courier new'=
, monospace;">__temp </span><font face=3D"courier new, monospace">);</=
font></div><div><font face=3D"courier new, monospace"> =
auto&& value =3D std::get<1>(</font><span style=3D"col=
or: rgb(0, 0, 0); font-family: 'courier new', monospace;">__temp </spa=
n><font face=3D"courier new, monospace">);</font></div><div><span style=3D"=
color: rgb(0, 0, 0);"><font face=3D"courier new, monospace"> &=
nbsp; ...</font></span></div><div><span style=3D"color: rgb(0, 0, 0)=
;"><font face=3D"courier new, monospace"> }</font></span></div=
><div><span style=3D"color: rgb(0, 0, 0);"><font face=3D"arial, sans-serif"=
><br></font></span></div><div><font color=3D"#000000" face=3D"arial, sans-s=
erif">Arguably this feature is just syntactic sugar, but this sort of tuple=
unpacking is very common in other languages (cf. Python, clojure), and I b=
elieve that it would decrease the verbosity (and increase the clarity) of t=
hings like multiple return values, map iterators, zip iterators and other s=
imilar constructions. Also, one could make the argument that this hides typ=
es, but there seems to be an increasing trend towards type inference in C++=
(first auto, now auto return values), so I don't personally thing that thi=
s is a problem.</font></div><div><font color=3D"#000000" face=3D"arial, san=
s-serif"><br></font></div><div><font color=3D"#000000" face=3D"arial, sans-=
serif">What do people think?</font></div></div>
<p></p>
-- <br />
<br />
--- <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 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 />
------=_Part_698_11223515.1393525057974--
.
Author: Matthew Woehlke <mw_triad@users.sourceforge.net>
Date: Thu, 27 Feb 2014 13:52:20 -0500
Raw View
On 2014-02-27 13:17, leszek.swirski@gmail.com wrote:
> Currently, given a function that returns a tuple
>
> std::tuple<int,double> foo() {
> return std::make_tuple(1, 2.0);
> }
>
> one can access the returned values using std::tie
>
> int a;
> double b;
> std::tie(a,b) = foo();
>
> but then you have to know the return types. Alternatively, without
> specifying types one can use std::get:
>
> auto ret = foo();
> auto&& a = std::get<0>(ret);
> auto&& b = std::get<1>(ret);
>
> but then you create a new variable and the whole thing seems unnecessarily
> verbose. Neither of these solutions seems particularly clean to me.
>
> Would it be possible to introduce a new syntax, which both declares the
> tuple element variables using the correct type, and assigns to them?
> Something like
>
> auto (a,b) = foo();
Regardless of other considerations, I like this syntax ever so much
better than either of the above. (Looks like Python :-). I was just
thinking the other day how it's a shame that C++ can't handle
multi-value returns as nicely as Python... and here you are proposing
it! I like!)
Not that anyone these days *shouldn't* be using auto, but I wonder,
should we also allow e.g.:
(int a, double b) = foo();
....?
Also, I would like if the following are also valid:
auto const&& (a, b) = foo(); // a and b are both const
auto (const&& a, b) = foo(); // a -> auto const&&, b -> auto
> An interesting application would be tuple unpacking in ranged-for loops,
> where one could write
>
> for (auto(key,value) : get_map()) {
> ...
> }
*OMG*... this could save me from writing iterator-based loops!! :-D
Now we just need functions in std to unpack indexed (std::enumerate) and
key/value (std::iterate?) containers like this... That *could* be a
separate proposal but this suddenly makes them really attractive.
Related: bonus points if 'auto (a,b)' can also be used with std::pair.
Maybe it should be implemented like range-based for, i.e. creates an
anonymous temporary and uses a well-known function ('get<index>') to get
each value. Then as long as there is a std::get<0>(std::pair<...>) this
will just magically work, and can also be extended to user types.
Also, the above would mean the compiler effectively is just generating
code like in your (elided) examples, which should make it much easier to
implement the non-auto-valued and with-type-modifier variants as I
suggested above, since those only entail relatively simple logic to
combine the type-and-or-modifier correctly to form each "longhand"
declaration.
IOW:
[A0] ([A1] N1, [A2] N2, ...) = expr;
....is expanded by the compiler to become:
auto&& __temporary__ = expr;
A0 A1 N1 = get<0>(__temporary__);
A0 A2 N2 = get<1>(__temporary__);
...
....where An are "optional" (as long as either A0 is provided or every
other An is provided). And of course all A0 An must be valid type
specifiers.
(Note that the above implies the same rule as range-for that 'std' is an
associated namespace.)
--
Matthew
--
---
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/.
.
Author: leszek.swirski@gmail.com
Date: Thu, 27 Feb 2014 16:33:42 -0800 (PST)
Raw View
------=_Part_28_10061193.1393547622935
Content-Type: text/plain; charset=UTF-8
On Thursday, 27 February 2014 18:52:20 UTC, Matthew Woehlke wrote:
>
> should we also allow e.g.:
>
> (int a, double b) = foo();
>
I was thinking this too, but I'm a little bit worried about having
parenthesised expressions as L-values -- I'm not sure how pleased the
parser people would be about something like this, especially since (a,b) is
a perfectly valid L-value (and not a tuple unpacking). I'm not sure how
common it would be for someone to want to unpack a tuple into different
types than are found in the tuple, so perhaps this is an example where it's
best to optimise for the common case.
> Also, I would like if the following are also valid:
>
> auto const&& (a, b) = foo(); // a and b are both const
>
> auto (const&& a, b) = foo(); // a -> auto const&&, b -> auto
>
I see no (immediate) reason why not, though I'm not sure how well this
would interact with, for example, tuples containing references. Would
auto(a,b) cause unnecessary copies? Would decltype(auto) (a,b) need to be a
thing?
> Now we just need functions in std to unpack indexed (std::enumerate) and
> key/value (std::iterate?) containers like this... That *could* be a
> separate proposal but this suddenly makes them really attractive.
>
My need for something like std::enumerate was one of the main reasons this
proposal started formulating itself in my head.
> Related: bonus points if 'auto (a,b)' can also be used with std::pair.
> Maybe it should be implemented like range-based for, i.e. creates an
> anonymous temporary and uses a well-known function ('get<index>') to get
> each value. Then as long as there is a std::get<0>(std::pair<...>) this
> will just magically work, and can also be extended to user types.
>
Also exactly what I was thinking, calling get<i> using ADL in a similar way
to range-based for's ADL use of begin. We'd probably also need to check if
the number of arguments matches the number of variables, which would be
done using an ADL of tuple_size.
> Also, the above would mean the compiler effectively is just generating
> code like in your (elided) examples, [...]
>
> [A0] ([A1] N1, [A2] N2, ...) = expr;
>
> ...is expanded by the compiler to become:
>
> auto&& __temporary__ = expr;
> A0 A1 N1 = get<0>(__temporary__);
> A0 A2 N2 = get<1>(__temporary__);
>
With the small difference that it all counts as a single statement (single
expression?)
--
---
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_28_10061193.1393547622935
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr">On Thursday, 27 February 2014 18:52:20 UTC, Matthew Woehlk=
e wrote:<blockquote class=3D"gmail_quote" style=3D"margin: 0;margin-left: =
0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;">should we also allow =
e.g.:
<br>
<br>(int a, double b) =3D foo();
<br></blockquote><div><br></div><div>I was thinking this too, but I'm a lit=
tle bit worried about having parenthesised expressions as L-values -- I'm n=
ot sure how pleased the parser people would be about something like this, e=
specially since (a,b) is a perfectly valid L-value (and not a tuple unpacki=
ng). I'm not sure how common it would be for someone to want to unpack a tu=
ple into different types than are found in the tuple, so perhaps this is an=
example where it's best to optimise for the common case.</div><div> <=
/div><blockquote class=3D"gmail_quote" style=3D"margin: 0;margin-left: 0.8e=
x;border-left: 1px #ccc solid;padding-left: 1ex;">Also, I would like if the=
following are also valid:
<br>
<br> auto const&& (a, b) =3D foo(); // a and b are both=
const
<br>
<br> auto (const&& a, b) =3D foo(); // a -> auto con=
st&&, b -> auto
<br></blockquote><div><br></div><div>I see no (immediate) reason why not, t=
hough I'm not sure how well this would interact with, for example, tuples c=
ontaining references. Would auto(a,b) cause unnecessary copies? Would declt=
ype(auto) (a,b) need to be a thing?</div><div> </div><blockquote class=
=3D"gmail_quote" style=3D"margin: 0;margin-left: 0.8ex;border-left: 1px #cc=
c solid;padding-left: 1ex;">Now we just need functions in std to unpack ind=
exed (std::enumerate) and=20
<br>key/value (std::iterate?) containers like this... That *could* be a=20
<br>separate proposal but this suddenly makes them really attractive.
<br></blockquote><div><br></div><div>My need for something like std::enumer=
ate was one of the main reasons this proposal started formulating itself in=
my head.<br></div><div> </div><blockquote class=3D"gmail_quote" style=
=3D"margin: 0;margin-left: 0.8ex;border-left: 1px #ccc solid;padding-left: =
1ex;">Related: bonus points if 'auto (a,b)' can also be used with std::pair=
..=20
<br>Maybe it should be implemented like range-based for, i.e. creates an=20
<br>anonymous temporary and uses a well-known function ('get<index>')=
to get=20
<br>each value. Then as long as there is a std::get<0>(std::pair<.=
...>) this=20
<br>will just magically work, and can also be extended to user types.
<br></blockquote><div><br></div><div>Also exactly what I was thinking, call=
ing get<i> using ADL in a similar way to range-based for's ADL use of=
begin. We'd probably also need to check if the number of arguments matches=
the number of variables, which would be done using an ADL of tuple_size.</=
div><div> </div><blockquote class=3D"gmail_quote" style=3D"margin: 0;m=
argin-left: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;">Also, the=
above would mean the compiler effectively is just generating=20
<br>code like in your (elided) examples, [...]<br>
<br> [A0] ([A1] N1, [A2] N2, ...) =3D expr;
<br>
<br>...is expanded by the compiler to become:
<br>
<br> auto&& __temporary__ =3D expr;
<br> A0 A1 N1 =3D get<0>(__temporary__);
<br> A0 A2 N2 =3D get<1>(__temporary__);
<br></blockquote><div><br></div><div>With the small difference that it all =
counts as a single statement (single expression?)</div></div>
<p></p>
-- <br />
<br />
--- <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 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 />
------=_Part_28_10061193.1393547622935--
.
Author: Matthew Woehlke <mw_triad@users.sourceforge.net>
Date: Fri, 28 Feb 2014 12:46:07 -0500
Raw View
On 2014-02-27 19:33, leszek.swirski@gmail.com wrote:
> On Thursday, 27 February 2014 18:52:20 UTC, Matthew Woehlke wrote:
>> should we also allow e.g.:
>>
>> (int a, double b) = foo();
>
> I was thinking this too, but I'm a little bit worried about having
> parenthesised expressions as L-values -- I'm not sure how pleased the
> parser people would be about something like this, especially since (a,b) is
> a perfectly valid L-value (and not a tuple unpacking). I'm not sure how
> common it would be for someone to want to unpack a tuple into different
> types than are found in the tuple, so perhaps this is an example where it's
> best to optimise for the common case.
But it's not just the different-types case. It's also type modifiers
e.g. 'const', '&', '&&'.
(I wasn't even thinking *different* types anyway, but specifying the
types explicitly rather than using 'auto'.)
Right now, e.g. '(int a, double b)' is not valid syntax; it seems it
should be possible to detect that the components look like declarations
and treat them as tuple unpacking. But I'm not a parser writer, so it
wouldn't hurt to have someone who is weigh in.
Going further, should:
int a;
double b;
(a, b) = foo(); // foo() -> tuple<int, double>
....be allowed? I'd say 'no' since the above is legal in current C++ if
foo() -> double (or something convertible to double). IOW, only invoke
tuple initialization if some An (referring to syntax below) is non-empty.
>> Also, I would like if the following are also valid:
>>
>> auto const&& (a, b) = foo(); // a and b are both const
>> auto (const&& a, b) = foo(); // a -> auto const&&, b -> auto
>
> I see no (immediate) reason why not, though I'm not sure how well this
> would interact with, for example, tuples containing references.
They should behave exactly as I illustrated later in my previously mail,
i.e. the second is equivalent to:
auto&& __temp = foo();
auto const&& a = get<0>(__temp);
auto b = get<1>(__temp);
So there is no new behavior being introduced here.
> Would auto(a,b) cause unnecessary copies?
This (IMHO) should be exactly equivalent to 'auto a = get<0>(...)',
etc.. If that would cause copies, then so will 'auto (a, ...)'.
> Would decltype(auto) (a,b) need to be a thing?
I'm not sure it is possible; it would imply knowing what tuple or
tuple-like type 'auto (a,b)' was assigned from (e.g. tuple, pair, ...?).
(More interesting: do we allow '(int a, double b)' as a bare
declaration? We *could*, though I don't see a benefit in doing so.)
>> Related: bonus points if 'auto (a,b)' can also be used with std::pair.
>> Maybe it should be implemented like range-based for, i.e. creates an
>> anonymous temporary and uses a well-known function ('get<index>') to get
>> each value. Then as long as there is a std::get<0>(std::pair<...>) this
>> will just magically work, and can also be extended to user types.
>
> Also exactly what I was thinking, calling get<i> using ADL in a similar way
> to range-based for's ADL use of begin. We'd probably also need to check if
> the number of arguments matches the number of variables, which would be
> done using an ADL of tuple_size.
Do we? We could also allow the caller to simply discard unneeded
elements. This would tremendously simplify things (no need to check
tuple_size or to implement it for user types; just rely on get<i> to be
a compile error if no such element i) as far as the implementation.
>> Also, the above would mean the compiler effectively is just generating
>> code like in your (elided) examples, [...]
>>
>> [A0] ([A1] N1, [A2] N2, ...) = expr;
>>
>> ...is expanded by the compiler to become:
>>
>> auto&& __temporary__ = expr;
>> A0 A1 N1 = get<0>(__temporary__);
>> A0 A2 N2 = get<1>(__temporary__);
>
> With the small difference that it all counts as a single statement (single
> expression?)
I think yes, if it matters. (I wasn't thinking of this as an actual code
transformation that would then be subject to rules where it would
matter, but rather the compiler would generate assembly "as if" the code
was as above. IOW, scoping, building of symbol trees, etc. has already
been performed. Actually this works even for range-based for, as the
assignment of the value happens inside the loop. Implying of course that
the range-based for transformations happen first. So, also, similar to
the "as-if code expansion" done to implement range-based for.)
Interesting question: is this a permissible declaration inside of if()?
And if so, what assignment is used as the conditional expression?
(First? Last? All of them?)
--
Matthew
--
---
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/.
.
Author: rouslankorneychuk@gmail.com
Date: Thu, 15 May 2014 17:17:03 -0700 (PDT)
Raw View
------=_Part_224_33262076.1400199423456
Content-Type: text/plain; charset=UTF-8
I thought of an alternative syntax to consider, which might require less
drastic changes to the language. Something like this:
{auto key; double value} = foo();
which would be conceptually equivalent to:
struct __anonymous_t__ {
std::tuple_element<0,decltype(foo())>::type key;
double value;
template<typename T1,typename T2>
__anonymous_t__(const std::tuple<T1,T2> &vals) :
key(std::get<0>(vals)), value(std::get<1>(vals) {}
} __anonymous_v__ = foo();
This way also doesn't require any new rules for how types are specified.
--
---
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_224_33262076.1400199423456
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr">I thought of an alternative syntax to consider, which migh=
t require less drastic changes to the language. Something like this:<br><br=
><span style=3D"font-family: courier new,monospace;"> {au=
to key; double value} =3D foo();</span><br><br>which would be conceptually =
equivalent to:<br><br><span style=3D"font-family: courier new,monospace;">&=
nbsp; struct __anonymous_t__ {<br>  =
; std::tuple_element<0,decltype(foo())>::type key;<br>&nb=
sp; double value;<br><br> &n=
bsp; template<typename T1,typename T2><br>&nb=
sp; __anonymous_t__(const std::tuple<=
;T1,T2> &vals) : key(std::get<0>(vals)), value(std::get<1&g=
t;(vals) {}<br> } __anonymous_v__ =3D foo();</span><br><b=
r>This way also doesn't require any new rules for how types are specified.<=
br></div>
<p></p>
-- <br />
<br />
--- <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 />
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/">http://groups.google.com/a/isocpp.org/group/std-proposals/<=
/a>.<br />
------=_Part_224_33262076.1400199423456--
.
Author: Richard Smith <richard@metafoo.co.uk>
Date: Thu, 15 May 2014 18:24:49 -0700
Raw View
--047d7b2e548aa0816c04f97a4707
Content-Type: text/plain; charset=UTF-8
On Thu, May 15, 2014 at 5:17 PM, <rouslankorneychuk@gmail.com> wrote:
> I thought of an alternative syntax to consider, which might require less
> drastic changes to the language. Something like this:
>
> {auto key; double value} = foo();
>
Unfortunately, this syntax is not likely to be a good fit. The compiler has
no idea whether it's looking at a compound-statement or your new syntax
until it sees that there's a ';' missing before the '}'. That's a lot of
lookahead, and would apply to any statement that starts with a '{' (which
is extremely common).
which would be conceptually equivalent to:
>
> struct __anonymous_t__ {
> std::tuple_element<0,decltype(foo())>::type key;
> double value;
>
> template<typename T1,typename T2>
> __anonymous_t__(const std::tuple<T1,T2> &vals) :
> key(std::get<0>(vals)), value(std::get<1>(vals) {}
> } __anonymous_v__ = foo();
>
> This way also doesn't require any new rules for how types are specified.
>
> --
>
> ---
> 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/.
>
--
---
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/.
--047d7b2e548aa0816c04f97a4707
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr"><div class=3D"gmail_extra"><div class=3D"gmail_quote">On T=
hu, May 15, 2014 at 5:17 PM, <span dir=3D"ltr"><<a href=3D"mailto:rousl=
ankorneychuk@gmail.com" target=3D"_blank">rouslankorneychuk@gmail.com</a>&g=
t;</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 dir=3D"ltr">I thought of an alternative=
syntax to consider, which might require less drastic changes to the langua=
ge. Something like this:<br>
<br><span style=3D"font-family:courier new,monospace">=C2=A0=C2=A0=C2=A0 {a=
uto key; double value} =3D foo();</span><br></div></blockquote><div><br></d=
iv><div>Unfortunately, this syntax is not likely to be a good fit. The comp=
iler has no idea whether it's looking at a compound-statement or your n=
ew syntax until it sees that there's a ';' missing before the &=
#39;}'. That's a lot of lookahead, and would apply to any statement=
that starts with a '{' (which is extremely common).</div>
<div><br></div><blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex=
;border-left:1px #ccc solid;padding-left:1ex"><div dir=3D"ltr">which would =
be conceptually equivalent to:<br><br><span style=3D"font-family:courier ne=
w,monospace">=C2=A0=C2=A0=C2=A0 struct __anonymous_t__ {<br>
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 std::tuple_element<0,decltype=
(foo())>::type key;<br>=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 double=
value;<br><br>=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 template<typen=
ame T1,typename T2><br>=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 __anon=
ymous_t__(const std::tuple<T1,T2> &vals) : key(std::get<0>(=
vals)), value(std::get<1>(vals) {}<br>
=C2=A0=C2=A0=C2=A0 } __anonymous_v__ =3D foo();</span><br><br>This way also=
doesn't require any new rules for how types are specified.<br></div><d=
iv class=3D"HOEnZb"><div class=3D"h5">
<p></p>
-- <br>
<br>
--- <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" target=3D"_=
blank">std-proposals+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/" target=3D"_blank">http://groups.google.com/a/isocpp.org/gro=
up/std-proposals/</a>.<br>
</div></div></blockquote></div><br></div></div>
<p></p>
-- <br />
<br />
--- <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 />
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 />
--047d7b2e548aa0816c04f97a4707--
.
Author: Richard Smith <richard@metafoo.co.uk>
Date: Thu, 15 May 2014 18:27:45 -0700
Raw View
--047d7b67663014eefb04f97a5269
Content-Type: text/plain; charset=UTF-8
On Thu, May 15, 2014 at 6:24 PM, Richard Smith <richard@metafoo.co.uk>wrote:
> On Thu, May 15, 2014 at 5:17 PM, <rouslankorneychuk@gmail.com> wrote:
>
>> I thought of an alternative syntax to consider, which might require less
>> drastic changes to the language. Something like this:
>>
>> {auto key; double value} = foo();
>>
>
> Unfortunately, this syntax is not likely to be a good fit. The compiler
> has no idea whether it's looking at a compound-statement or your new syntax
> until it sees that there's a ';' missing before the '}'. That's a lot of
> lookahead, and would apply to any statement that starts with a '{' (which
> is extremely common).
>
Random though: allow anonymous structs, with initializers:
struct { ... } = foo();
and, more generally, support aggregate initialization and assignment from
an expression E by calling get<N>(E).
(Though this would need some finessing to allow 'auto'.)
which would be conceptually equivalent to:
>>
>> struct __anonymous_t__ {
>> std::tuple_element<0,decltype(foo())>::type key;
>> double value;
>>
>> template<typename T1,typename T2>
>> __anonymous_t__(const std::tuple<T1,T2> &vals) :
>> key(std::get<0>(vals)), value(std::get<1>(vals) {}
>> } __anonymous_v__ = foo();
>>
>> This way also doesn't require any new rules for how types are specified.
>>
>> --
>>
>> ---
>> 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/.
>>
>
>
--
---
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/.
--047d7b67663014eefb04f97a5269
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr"><div class=3D"gmail_extra"><div class=3D"gmail_quote">On T=
hu, May 15, 2014 at 6:24 PM, Richard Smith <span dir=3D"ltr"><<a href=3D=
"mailto:richard@metafoo.co.uk" target=3D"_blank">richard@metafoo.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"><div dir=3D"ltr"><div class=3D"gmail_extra">=
<div class=3D"gmail_quote"><div class=3D"">On Thu, May 15, 2014 at 5:17 PM,=
<span dir=3D"ltr"><<a href=3D"mailto:rouslankorneychuk@gmail.com" targ=
et=3D"_blank">rouslankorneychuk@gmail.com</a>></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 dir=3D"ltr">I thought of an alternative=
syntax to consider, which might require less drastic changes to the langua=
ge. Something like this:<br>
<br><span style=3D"font-family:courier new,monospace">=C2=A0=C2=A0=C2=A0 {a=
uto key; double value} =3D foo();</span><br></div></blockquote><div><br></d=
iv></div><div>Unfortunately, this syntax is not likely to be a good fit. Th=
e compiler has no idea whether it's looking at a compound-statement or =
your new syntax until it sees that there's a ';' missing before=
the '}'. That's a lot of lookahead, and would apply to any sta=
tement that starts with a '{' (which is extremely common).</div>
</div></div></div></blockquote><div><br></div><div>Random though: allow ano=
nymous structs, with initializers:</div><div><br></div><div>struct { ... } =
=3D foo();</div><div><br></div><div>and, more generally, support aggregate =
initialization and assignment from an expression E by calling get<N>(=
E).</div>
<div><br></div><div>(Though this would need some finessing to allow 'au=
to'.)</div><div><br></div><blockquote class=3D"gmail_quote" style=3D"ma=
rgin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir=3D"lt=
r">
<div class=3D"gmail_extra"><div class=3D"gmail_quote"><div class=3D""><bloc=
kquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1px #cc=
c solid;padding-left:1ex"><div dir=3D"ltr">which would be conceptually equi=
valent to:<br>
<br><span style=3D"font-family:courier new,monospace">=C2=A0=C2=A0=C2=A0 st=
ruct __anonymous_t__ {<br>
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 std::tuple_element<0,decltype=
(foo())>::type key;<br>=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 double=
value;<br><br>=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 template<typen=
ame T1,typename T2><br>=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 __anon=
ymous_t__(const std::tuple<T1,T2> &vals) : key(std::get<0>(=
vals)), value(std::get<1>(vals) {}<br>
=C2=A0=C2=A0=C2=A0 } __anonymous_v__ =3D foo();</span><br><br>This way also=
doesn't require any new rules for how types are specified.<br></div><d=
iv><div>
<p></p>
-- <br>
<br>
--- <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" target=3D"_=
blank">std-proposals+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/" target=3D"_blank">http://groups.google.com/a/isocpp.org/gro=
up/std-proposals/</a>.<br>
</div></div></blockquote></div></div><br></div></div>
</blockquote></div><br></div></div>
<p></p>
-- <br />
<br />
--- <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 />
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 />
--047d7b67663014eefb04f97a5269--
.
Author: Andrew Tomazos <andrewtomazos@gmail.com>
Date: Fri, 16 May 2014 03:54:34 +0200
Raw View
--047d7bd6be0205e83404f97ab2e4
Content-Type: text/plain; charset=UTF-8
I think the root problem is that you want to initialize multiple values, by
decomposing a *single* expression of compound sequence type (for example
structs, arrays, tuples, pairs, etc).
// Example compound sequence type values:
struct { A a; B b } s = ...;
T arr[3] = ...;
std::tuple<A,B,C> t = ...;
std::pair<A,B> p = ...;
// use the above to initialize these with single expression somehow:
A a; B b; // = s
T a; T b; T c; // = arr
A a; B b; C c; // = t
A a; B b; // = p
I think you're suggesting:
struct { A a; B b; } = s;
struct { T a; T b; T c; } = arr;
struct { A a; B b; C c; } = t;
struct { A a; B b; } = p;
But it's not clear if the members of these "structs" are introduced into
the enclosing scope. Unless the names are, then it kind of defeats the
purpose doesn't it?
Perhaps a different name for this idea:
decltie { A a; B b; } = s;
decltie { T a; T b; T c; } = arr;
decltie { A a; B b; C c; } = t;
decltie { A a; B b; } = p;
The body of decltie consists of syntactically uninitialized declarations
placed in the enclosing scope, followed by a single initializer. The
initializer is decomposed with get<N>(E) and initializes each of the
contained declarations.
On Fri, May 16, 2014 at 3:27 AM, Richard Smith <richard@metafoo.co.uk>wrote:
> On Thu, May 15, 2014 at 6:24 PM, Richard Smith <richard@metafoo.co.uk>wrote:
>
>> On Thu, May 15, 2014 at 5:17 PM, <rouslankorneychuk@gmail.com> wrote:
>>
>>> I thought of an alternative syntax to consider, which might require less
>>> drastic changes to the language. Something like this:
>>>
>>> {auto key; double value} = foo();
>>>
>>
>> Unfortunately, this syntax is not likely to be a good fit. The compiler
>> has no idea whether it's looking at a compound-statement or your new syntax
>> until it sees that there's a ';' missing before the '}'. That's a lot of
>> lookahead, and would apply to any statement that starts with a '{' (which
>> is extremely common).
>>
>
> Random though: allow anonymous structs, with initializers:
>
> struct { ... } = foo();
>
> and, more generally, support aggregate initialization and assignment from
> an expression E by calling get<N>(E).
>
> (Though this would need some finessing to allow 'auto'.)
>
> which would be conceptually equivalent to:
>>>
>>> struct __anonymous_t__ {
>>> std::tuple_element<0,decltype(foo())>::type key;
>>> double value;
>>>
>>> template<typename T1,typename T2>
>>> __anonymous_t__(const std::tuple<T1,T2> &vals) :
>>> key(std::get<0>(vals)), value(std::get<1>(vals) {}
>>> } __anonymous_v__ = foo();
>>>
>>> This way also doesn't require any new rules for how types are specified.
>>>
>>> --
>>>
>>> ---
>>> 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/.
>>>
>>
>>
> --
>
> ---
> 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/.
>
--
---
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/.
--047d7bd6be0205e83404f97ab2e4
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr">I think the root problem is that you want to initialize mu=
ltiple values, by decomposing a *single* expression of compound sequence ty=
pe (for example structs, arrays, tuples, pairs, etc).<div><br></div><div>=
=C2=A0 =C2=A0 // Example compound sequence type values:</div>
<div>=C2=A0 =C2=A0 struct { A a; B b } s =3D ...;</div><div>=C2=A0 =C2=A0 T=
arr[3] =3D ...;</div><div>=C2=A0 =C2=A0 std::tuple<A,B,C> t =3D ...;=
</div><div>=C2=A0 =C2=A0 std::pair<A,B> p =3D ...;</div><div><br></di=
v><div>=C2=A0 =C2=A0 // use the above to initialize these with single expre=
ssion somehow:</div>
<div>=C2=A0 =C2=A0 A a; B b; =C2=A0// =3D s</div><div>=C2=A0 =C2=A0 T a; T =
b; T c; // =3D arr</div><div><div>=C2=A0 =C2=A0 A a; B b; C c; // =3D t</di=
v><div>=C2=A0 =C2=A0 A a; B b; // =3D p</div><div><br></div><div>I think yo=
u're suggesting:</div><div><div>=C2=A0</div><div>=C2=A0 =C2=A0 struct {=
A a; B b; } =C2=A0=3D s;</div>
<div>=C2=A0 =C2=A0 struct { T a; T b; T c; } =3D arr;</div><div><div>=C2=A0=
=C2=A0 struct { A a; B b; C c; } =3D t;</div><div>=C2=A0 =C2=A0 struct { A=
a; B b; } =3D p;</div><div><br></div></div></div><div>But it's not cle=
ar if the members of these "structs" are introduced into the encl=
osing scope. =C2=A0Unless the names are, then it kind of defeats the purpos=
e doesn't it?</div>
<div><br></div><div>Perhaps a different name for this idea:</div><div><br><=
/div><div><div>=C2=A0 =C2=A0 decltie { A a; B b; } =C2=A0=3D s;</div><div>=
=C2=A0 =C2=A0=C2=A0decltie=C2=A0{ T a; T b; T c; } =3D arr;</div><div><div>=
=C2=A0 =C2=A0=C2=A0decltie=C2=A0{ A a; B b; C c; } =3D t;</div>
<div>=C2=A0 =C2=A0=C2=A0decltie=C2=A0{ A a; B b; } =3D p;</div></div></div>=
<div><br></div><div>The body of decltie consists of syntactically uninitial=
ized declarations placed in the enclosing scope, followed by a single initi=
alizer. =C2=A0The initializer is decomposed with get<N>(E) and initia=
lizes each of the contained declarations.</div>
<div><br></div><div><br></div><div><div class=3D"gmail_extra"><br><br><div =
class=3D"gmail_quote">On Fri, May 16, 2014 at 3:27 AM, Richard Smith <span =
dir=3D"ltr"><<a href=3D"mailto:richard@metafoo.co.uk" target=3D"_blank">=
richard@metafoo.co.uk</a>></span> wrote:<br>
<blockquote class=3D"gmail_quote" style=3D"margin:0px 0px 0px 0.8ex;border-=
left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;p=
adding-left:1ex"><div dir=3D"ltr"><div class=3D"gmail_extra"><div class=3D"=
gmail_quote">
<div class=3D"">On Thu, May 15, 2014 at 6:24 PM, Richard Smith <span dir=3D=
"ltr"><<a href=3D"mailto:richard@metafoo.co.uk" target=3D"_blank">richar=
d@metafoo.co.uk</a>></span> wrote:<br>
<blockquote class=3D"gmail_quote" style=3D"margin:0px 0px 0px 0.8ex;border-=
left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;p=
adding-left:1ex"><div dir=3D"ltr"><div class=3D"gmail_extra"><div class=3D"=
gmail_quote">
<div>On Thu, May 15, 2014 at 5:17 PM, <span dir=3D"ltr"><<a href=3D"mai=
lto:rouslankorneychuk@gmail.com" target=3D"_blank">rouslankorneychuk@gmail.=
com</a>></span> wrote:<br>
<blockquote class=3D"gmail_quote" style=3D"margin:0px 0px 0px 0.8ex;border-=
left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;p=
adding-left:1ex"><div dir=3D"ltr">I thought of an alternative syntax to con=
sider, which might require less drastic changes to the language. Something =
like this:<br>
<br><span style=3D"font-family:'courier new',monospace">=C2=A0=C2=
=A0=C2=A0 {auto key; double value} =3D foo();</span><br></div></blockquote>=
<div><br></div></div><div>Unfortunately, this syntax is not likely to be a =
good fit. The compiler has no idea whether it's looking at a compound-s=
tatement or your new syntax until it sees that there's a ';' mi=
ssing before the '}'. That's a lot of lookahead, and would appl=
y to any statement that starts with a '{' (which is extremely commo=
n).</div>
</div></div></div></blockquote><div><br></div></div><div>Random though: all=
ow anonymous structs, with initializers:</div><div><br></div><div>struct { =
.... } =3D foo();</div><div><br></div><div>and, more generally, support aggr=
egate initialization and assignment from an expression E by calling get<=
N>(E).</div>
<div><br></div><div>(Though this would need some finessing to allow 'au=
to'.)</div><div class=3D""><div><br></div><blockquote class=3D"gmail_qu=
ote" style=3D"margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-co=
lor:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
<div dir=3D"ltr">
<div class=3D"gmail_extra"><div class=3D"gmail_quote"><div><blockquote clas=
s=3D"gmail_quote" style=3D"margin:0px 0px 0px 0.8ex;border-left-width:1px;b=
order-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"=
><div dir=3D"ltr">
which would be conceptually equivalent to:<br>
<br><span style=3D"font-family:'courier new',monospace">=C2=A0=C2=
=A0=C2=A0 struct __anonymous_t__ {<br>
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 std::tuple_element<0,decltype=
(foo())>::type key;<br>=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 double=
value;<br><br>=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 template<typen=
ame T1,typename T2><br>=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 __anon=
ymous_t__(const std::tuple<T1,T2> &vals) : key(std::get<0>(=
vals)), value(std::get<1>(vals) {}<br>
=C2=A0=C2=A0=C2=A0 } __anonymous_v__ =3D foo();</span><br><br>This way also=
doesn't require any new rules for how types are specified.<br></div><d=
iv><div>
<p></p>
-- <br>
<br>
--- <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" target=3D"_=
blank">std-proposals+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/" target=3D"_blank">http://groups.google.com/a/isocpp.org/gro=
up/std-proposals/</a>.<br>
</div></div></blockquote></div></div><br></div></div>
</blockquote></div></div><br></div></div><div class=3D""><div class=3D"h5">
<p></p>
-- <br>
<br>
--- <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" target=3D"_=
blank">std-proposals+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/" target=3D"_blank">http://groups.google.com/a/isocpp.org/gro=
up/std-proposals/</a>.<br>
</div></div></blockquote></div><br></div></div></div></div>
<p></p>
-- <br />
<br />
--- <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 />
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 />
--047d7bd6be0205e83404f97ab2e4--
.
Author: Andrew Tomazos <andrewtomazos@gmail.com>
Date: Fri, 16 May 2014 03:57:03 +0200
Raw View
--001a11c30a4adf67a404f97aba1b
Content-Type: text/plain; charset=UTF-8
So the OPs example would become:
decltie { auto a, b; } = foo();
On Fri, May 16, 2014 at 3:54 AM, Andrew Tomazos <andrewtomazos@gmail.com>wrote:
> I think the root problem is that you want to initialize multiple values,
> by decomposing a *single* expression of compound sequence type (for example
> structs, arrays, tuples, pairs, etc).
>
> // Example compound sequence type values:
> struct { A a; B b } s = ...;
> T arr[3] = ...;
> std::tuple<A,B,C> t = ...;
> std::pair<A,B> p = ...;
>
> // use the above to initialize these with single expression somehow:
> A a; B b; // = s
> T a; T b; T c; // = arr
> A a; B b; C c; // = t
> A a; B b; // = p
>
> I think you're suggesting:
>
> struct { A a; B b; } = s;
> struct { T a; T b; T c; } = arr;
> struct { A a; B b; C c; } = t;
> struct { A a; B b; } = p;
>
> But it's not clear if the members of these "structs" are introduced into
> the enclosing scope. Unless the names are, then it kind of defeats the
> purpose doesn't it?
>
> Perhaps a different name for this idea:
>
> decltie { A a; B b; } = s;
> decltie { T a; T b; T c; } = arr;
> decltie { A a; B b; C c; } = t;
> decltie { A a; B b; } = p;
>
> The body of decltie consists of syntactically uninitialized declarations
> placed in the enclosing scope, followed by a single initializer. The
> initializer is decomposed with get<N>(E) and initializes each of the
> contained declarations.
>
>
>
>
> On Fri, May 16, 2014 at 3:27 AM, Richard Smith <richard@metafoo.co.uk>wrote:
>
>> On Thu, May 15, 2014 at 6:24 PM, Richard Smith <richard@metafoo.co.uk>wrote:
>>
>>> On Thu, May 15, 2014 at 5:17 PM, <rouslankorneychuk@gmail.com> wrote:
>>>
>>>> I thought of an alternative syntax to consider, which might require
>>>> less drastic changes to the language. Something like this:
>>>>
>>>> {auto key; double value} = foo();
>>>>
>>>
>>> Unfortunately, this syntax is not likely to be a good fit. The compiler
>>> has no idea whether it's looking at a compound-statement or your new syntax
>>> until it sees that there's a ';' missing before the '}'. That's a lot of
>>> lookahead, and would apply to any statement that starts with a '{' (which
>>> is extremely common).
>>>
>>
>> Random though: allow anonymous structs, with initializers:
>>
>> struct { ... } = foo();
>>
>> and, more generally, support aggregate initialization and assignment from
>> an expression E by calling get<N>(E).
>>
>> (Though this would need some finessing to allow 'auto'.)
>>
>> which would be conceptually equivalent to:
>>>>
>>>> struct __anonymous_t__ {
>>>> std::tuple_element<0,decltype(foo())>::type key;
>>>> double value;
>>>>
>>>> template<typename T1,typename T2>
>>>> __anonymous_t__(const std::tuple<T1,T2> &vals) :
>>>> key(std::get<0>(vals)), value(std::get<1>(vals) {}
>>>> } __anonymous_v__ = foo();
>>>>
>>>> This way also doesn't require any new rules for how types are specified.
>>>>
>>>> --
>>>>
>>>> ---
>>>> 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/.
>>>>
>>>
>>>
>> --
>>
>> ---
>> 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/.
>>
>
>
--
---
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/.
--001a11c30a4adf67a404f97aba1b
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr">So the OPs example would become:<div><br></div><div>=C2=A0=
=C2=A0 decltie { auto a, b; } =3D foo();</div></div><div class=3D"gmail_ex=
tra"><br><br><div class=3D"gmail_quote">On Fri, May 16, 2014 at 3:54 AM, An=
drew Tomazos <span dir=3D"ltr"><<a href=3D"mailto:andrewtomazos@gmail.co=
m" target=3D"_blank">andrewtomazos@gmail.com</a>></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 dir=3D"ltr">I think the root problem is=
that you want to initialize multiple values, by decomposing a *single* exp=
ression of compound sequence type (for example structs, arrays, tuples, pai=
rs, etc).<div>
<br></div><div>=C2=A0 =C2=A0 // Example compound sequence type values:</div=
>
<div>=C2=A0 =C2=A0 struct { A a; B b } s =3D ...;</div><div>=C2=A0 =C2=A0 T=
arr[3] =3D ...;</div><div>=C2=A0 =C2=A0 std::tuple<A,B,C> t =3D ...;=
</div><div>=C2=A0 =C2=A0 std::pair<A,B> p =3D ...;</div><div><br></di=
v><div>=C2=A0 =C2=A0 // use the above to initialize these with single expre=
ssion somehow:</div>
<div>=C2=A0 =C2=A0 A a; B b; =C2=A0// =3D s</div><div>=C2=A0 =C2=A0 T a; T =
b; T c; // =3D arr</div><div><div>=C2=A0 =C2=A0 A a; B b; C c; // =3D t</di=
v><div>=C2=A0 =C2=A0 A a; B b; // =3D p</div><div><br></div><div>I think yo=
u're suggesting:</div><div><div>=C2=A0</div><div>
=C2=A0 =C2=A0 struct { A a; B b; } =C2=A0=3D s;</div>
<div>=C2=A0 =C2=A0 struct { T a; T b; T c; } =3D arr;</div><div><div>=C2=A0=
=C2=A0 struct { A a; B b; C c; } =3D t;</div><div>=C2=A0 =C2=A0 struct { A=
a; B b; } =3D p;</div><div><br></div></div></div><div>But it's not cle=
ar if the members of these "structs" are introduced into the encl=
osing scope. =C2=A0Unless the names are, then it kind of defeats the purpos=
e doesn't it?</div>
<div><br></div><div>Perhaps a different name for this idea:</div><div><br><=
/div><div><div>=C2=A0 =C2=A0 decltie { A a; B b; } =C2=A0=3D s;</div><div>=
=C2=A0 =C2=A0=C2=A0decltie=C2=A0{ T a; T b; T c; } =3D arr;</div><div><div>=
=C2=A0 =C2=A0=C2=A0decltie=C2=A0{ A a; B b; C c; } =3D t;</div>
<div>=C2=A0 =C2=A0=C2=A0decltie=C2=A0{ A a; B b; } =3D p;</div></div></div>=
<div><br></div><div>The body of decltie consists of syntactically uninitial=
ized declarations placed in the enclosing scope, followed by a single initi=
alizer. =C2=A0The initializer is decomposed with get<N>(E) and initia=
lizes each of the contained declarations.</div>
<div><div class=3D"h5">
<div><br></div><div><br></div><div><div class=3D"gmail_extra"><br><br><div =
class=3D"gmail_quote">On Fri, May 16, 2014 at 3:27 AM, Richard Smith <span =
dir=3D"ltr"><<a href=3D"mailto:richard@metafoo.co.uk" target=3D"_blank">=
richard@metafoo.co.uk</a>></span> wrote:<br>
<blockquote class=3D"gmail_quote" style=3D"margin:0px 0px 0px 0.8ex;border-=
left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;p=
adding-left:1ex"><div dir=3D"ltr"><div class=3D"gmail_extra"><div class=3D"=
gmail_quote">
<div>On Thu, May 15, 2014 at 6:24 PM, Richard Smith <span dir=3D"ltr"><<=
a href=3D"mailto:richard@metafoo.co.uk" target=3D"_blank">richard@metafoo.c=
o.uk</a>></span> wrote:<br>
<blockquote class=3D"gmail_quote" style=3D"margin:0px 0px 0px 0.8ex;border-=
left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;p=
adding-left:1ex"><div dir=3D"ltr"><div class=3D"gmail_extra"><div class=3D"=
gmail_quote">
<div>On Thu, May 15, 2014 at 5:17 PM, <span dir=3D"ltr"><<a href=3D"mai=
lto:rouslankorneychuk@gmail.com" target=3D"_blank">rouslankorneychuk@gmail.=
com</a>></span> wrote:<br>
<blockquote class=3D"gmail_quote" style=3D"margin:0px 0px 0px 0.8ex;border-=
left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;p=
adding-left:1ex"><div dir=3D"ltr">I thought of an alternative syntax to con=
sider, which might require less drastic changes to the language. Something =
like this:<br>
<br><span style=3D"font-family:'courier new',monospace">=C2=A0=C2=
=A0=C2=A0 {auto key; double value} =3D foo();</span><br></div></blockquote>=
<div><br></div></div><div>Unfortunately, this syntax is not likely to be a =
good fit. The compiler has no idea whether it's looking at a compound-s=
tatement or your new syntax until it sees that there's a ';' mi=
ssing before the '}'. That's a lot of lookahead, and would appl=
y to any statement that starts with a '{' (which is extremely commo=
n).</div>
</div></div></div></blockquote><div><br></div></div><div>Random though: all=
ow anonymous structs, with initializers:</div><div><br></div><div>struct { =
.... } =3D foo();</div><div><br></div><div>and, more generally, support aggr=
egate initialization and assignment from an expression E by calling get<=
N>(E).</div>
<div><br></div><div>(Though this would need some finessing to allow 'au=
to'.)</div><div><div><br></div><blockquote class=3D"gmail_quote" style=
=3D"margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(20=
4,204,204);border-left-style:solid;padding-left:1ex">
<div dir=3D"ltr">
<div class=3D"gmail_extra"><div class=3D"gmail_quote"><div><blockquote clas=
s=3D"gmail_quote" style=3D"margin:0px 0px 0px 0.8ex;border-left-width:1px;b=
order-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"=
><div dir=3D"ltr">
which would be conceptually equivalent to:<br>
<br><span style=3D"font-family:'courier new',monospace">=C2=A0=C2=
=A0=C2=A0 struct __anonymous_t__ {<br>
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 std::tuple_element<0,decltype=
(foo())>::type key;<br>=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 double=
value;<br><br>=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 template<typen=
ame T1,typename T2><br>=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 __anon=
ymous_t__(const std::tuple<T1,T2> &vals) : key(std::get<0>(=
vals)), value(std::get<1>(vals) {}<br>
=C2=A0=C2=A0=C2=A0 } __anonymous_v__ =3D foo();</span><br><br>This way also=
doesn't require any new rules for how types are specified.<br></div><d=
iv><div>
<p></p>
-- <br>
<br>
--- <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" target=3D"_=
blank">std-proposals+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/" target=3D"_blank">http://groups.google.com/a/isocpp.org/gro=
up/std-proposals/</a>.<br>
</div></div></blockquote></div></div><br></div></div>
</blockquote></div></div><br></div></div><div><div>
<p></p>
-- <br>
<br>
--- <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" target=3D"_=
blank">std-proposals+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/" target=3D"_blank">http://groups.google.com/a/isocpp.org/gro=
up/std-proposals/</a>.<br>
</div></div></blockquote></div><br></div></div></div></div></div></div>
</blockquote></div><br></div>
<p></p>
-- <br />
<br />
--- <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 />
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 />
--001a11c30a4adf67a404f97aba1b--
.
Author: Richard Smith <richard@metafoo.co.uk>
Date: Thu, 15 May 2014 19:28:16 -0700
Raw View
--089e0158a82a829d7404f97b2a3a
Content-Type: text/plain; charset=UTF-8
On Thu, May 15, 2014 at 6:54 PM, Andrew Tomazos <andrewtomazos@gmail.com>wrote:
> I think the root problem is that you want to initialize multiple values,
> by decomposing a *single* expression of compound sequence type (for example
> structs, arrays, tuples, pairs, etc).
>
> // Example compound sequence type values:
> struct { A a; B b } s = ...;
> T arr[3] = ...;
> std::tuple<A,B,C> t = ...;
> std::pair<A,B> p = ...;
>
> // use the above to initialize these with single expression somehow:
> A a; B b; // = s
> T a; T b; T c; // = arr
> A a; B b; C c; // = t
> A a; B b; // = p
>
> I think you're suggesting:
>
> struct { A a; B b; } = s;
> struct { T a; T b; T c; } = arr;
> struct { A a; B b; C c; } = t;
> struct { A a; B b; } = p;
>
> But it's not clear if the members of these "structs" are introduced into
> the enclosing scope. Unless the names are, then it kind of defeats the
> purpose doesn't it?
>
I was imagining this working exactly like an anonymous union (or like C's
anonymous structs): the names are injected into the surrounding context.
Perhaps a different name for this idea:
>
> decltie { A a; B b; } = s;
> decltie { T a; T b; T c; } = arr;
> decltie { A a; B b; C c; } = t;
> decltie { A a; B b; } = p;
>
> The body of decltie consists of syntactically uninitialized declarations
> placed in the enclosing scope, followed by a single initializer. The
> initializer is decomposed with get<N>(E) and initializes each of the
> contained declarations.
>
Yes, a different keyword for this might be less confusing. I've also seen
this syntax suggested:
< A a, B b > = s;
.... which doesn't immediately seem to conflict with anything else.
On Fri, May 16, 2014 at 3:27 AM, Richard Smith <richard@metafoo.co.uk>wrote:
>
>> On Thu, May 15, 2014 at 6:24 PM, Richard Smith <richard@metafoo.co.uk>wrote:
>>
>>> On Thu, May 15, 2014 at 5:17 PM, <rouslankorneychuk@gmail.com> wrote:
>>>
>>>> I thought of an alternative syntax to consider, which might require
>>>> less drastic changes to the language. Something like this:
>>>>
>>>> {auto key; double value} = foo();
>>>>
>>>
>>> Unfortunately, this syntax is not likely to be a good fit. The compiler
>>> has no idea whether it's looking at a compound-statement or your new syntax
>>> until it sees that there's a ';' missing before the '}'. That's a lot of
>>> lookahead, and would apply to any statement that starts with a '{' (which
>>> is extremely common).
>>>
>>
>> Random though: allow anonymous structs, with initializers:
>>
>> struct { ... } = foo();
>>
>> and, more generally, support aggregate initialization and assignment from
>> an expression E by calling get<N>(E).
>>
>> (Though this would need some finessing to allow 'auto'.)
>>
>> which would be conceptually equivalent to:
>>>>
>>>> struct __anonymous_t__ {
>>>> std::tuple_element<0,decltype(foo())>::type key;
>>>> double value;
>>>>
>>>> template<typename T1,typename T2>
>>>> __anonymous_t__(const std::tuple<T1,T2> &vals) :
>>>> key(std::get<0>(vals)), value(std::get<1>(vals) {}
>>>> } __anonymous_v__ = foo();
>>>>
>>>> This way also doesn't require any new rules for how types are specified.
>>>>
>>>> --
>>>>
>>>> ---
>>>> 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/.
>>>>
>>>
>>>
>> --
>>
>> ---
>> 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/.
>>
>
> --
>
> ---
> 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/.
>
--
---
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/.
--089e0158a82a829d7404f97b2a3a
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr"><div class=3D"gmail_extra"><div class=3D"gmail_quote">On T=
hu, May 15, 2014 at 6:54 PM, Andrew Tomazos <span dir=3D"ltr"><<a href=
=3D"mailto:andrewtomazos@gmail.com" target=3D"_blank">andrewtomazos@gmail.c=
om</a>></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 dir=3D"ltr">I think the root problem is=
that you want to initialize multiple values, by decomposing a *single* exp=
ression of compound sequence type (for example structs, arrays, tuples, pai=
rs, etc).<div>
<br></div><div>=C2=A0 =C2=A0 // Example compound sequence type values:</div=
>
<div>=C2=A0 =C2=A0 struct { A a; B b } s =3D ...;</div><div>=C2=A0 =C2=A0 T=
arr[3] =3D ...;</div><div>=C2=A0 =C2=A0 std::tuple<A,B,C> t =3D ...;=
</div><div>=C2=A0 =C2=A0 std::pair<A,B> p =3D ...;</div><div><br></di=
v><div>=C2=A0 =C2=A0 // use the above to initialize these with single expre=
ssion somehow:</div>
<div>=C2=A0 =C2=A0 A a; B b; =C2=A0// =3D s</div><div>=C2=A0 =C2=A0 T a; T =
b; T c; // =3D arr</div><div><div>=C2=A0 =C2=A0 A a; B b; C c; // =3D t</di=
v><div>=C2=A0 =C2=A0 A a; B b; // =3D p</div><div><br></div><div>I think yo=
u're suggesting:</div><div><div>=C2=A0</div><div>
=C2=A0 =C2=A0 struct { A a; B b; } =C2=A0=3D s;</div>
<div>=C2=A0 =C2=A0 struct { T a; T b; T c; } =3D arr;</div><div><div>=C2=A0=
=C2=A0 struct { A a; B b; C c; } =3D t;</div><div>=C2=A0 =C2=A0 struct { A=
a; B b; } =3D p;</div><div><br></div></div></div><div>But it's not cle=
ar if the members of these "structs" are introduced into the encl=
osing scope. =C2=A0Unless the names are, then it kind of defeats the purpos=
e doesn't it?</div>
</div></div></blockquote><div><br></div><div>I was imagining this working e=
xactly like an anonymous union (or like C's anonymous structs): the nam=
es are injected into the surrounding context.</div><div><br></div><blockquo=
te class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1px #ccc so=
lid;padding-left:1ex">
<div dir=3D"ltr"><div><div>Perhaps a different name for this idea:</div><di=
v><br></div><div><div>=C2=A0 =C2=A0 decltie { A a; B b; } =C2=A0=3D s;</div=
><div>=C2=A0 =C2=A0=C2=A0decltie=C2=A0{ T a; T b; T c; } =3D arr;</div><div=
><div>=C2=A0 =C2=A0=C2=A0decltie=C2=A0{ A a; B b; C c; } =3D t;</div>
<div>=C2=A0 =C2=A0=C2=A0decltie=C2=A0{ A a; B b; } =3D p;</div></div></div>=
<div><br></div><div>The body of decltie consists of syntactically uninitial=
ized declarations placed in the enclosing scope, followed by a single initi=
alizer. =C2=A0The initializer is decomposed with get<N>(E) and initia=
lizes each of the contained declarations.</div>
</div></div></blockquote><div><br></div><div>Yes, a different keyword for t=
his might be less confusing. I've also seen this syntax suggested:</div=
><div><br></div><div>< A a, B b > =3D s;</div><div>=C2=A0<br></div><d=
iv>
.... which doesn't immediately seem to conflict with anything else.</div=
><div><br></div><blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8e=
x;border-left:1px #ccc solid;padding-left:1ex"><div dir=3D"ltr"><div><div><=
div class=3D"h5">
<div><div class=3D"gmail_extra"><div class=3D"gmail_quote">On Fri, May 16, =
2014 at 3:27 AM, Richard Smith <span dir=3D"ltr"><<a href=3D"mailto:rich=
ard@metafoo.co.uk" target=3D"_blank">richard@metafoo.co.uk</a>></span> w=
rote:<br>
<blockquote class=3D"gmail_quote" style=3D"margin:0px 0px 0px 0.8ex;border-=
left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;p=
adding-left:1ex"><div dir=3D"ltr"><div class=3D"gmail_extra"><div class=3D"=
gmail_quote">
<div>On Thu, May 15, 2014 at 6:24 PM, Richard Smith <span dir=3D"ltr"><<=
a href=3D"mailto:richard@metafoo.co.uk" target=3D"_blank">richard@metafoo.c=
o.uk</a>></span> wrote:<br>
<blockquote class=3D"gmail_quote" style=3D"margin:0px 0px 0px 0.8ex;border-=
left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;p=
adding-left:1ex"><div dir=3D"ltr"><div class=3D"gmail_extra"><div class=3D"=
gmail_quote">
<div>On Thu, May 15, 2014 at 5:17 PM, <span dir=3D"ltr"><<a href=3D"mai=
lto:rouslankorneychuk@gmail.com" target=3D"_blank">rouslankorneychuk@gmail.=
com</a>></span> wrote:<br>
<blockquote class=3D"gmail_quote" style=3D"margin:0px 0px 0px 0.8ex;border-=
left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;p=
adding-left:1ex"><div dir=3D"ltr">I thought of an alternative syntax to con=
sider, which might require less drastic changes to the language. Something =
like this:<br>
<br><span style=3D"font-family:'courier new',monospace">=C2=A0=C2=
=A0=C2=A0 {auto key; double value} =3D foo();</span><br></div></blockquote>=
<div><br></div></div><div>Unfortunately, this syntax is not likely to be a =
good fit. The compiler has no idea whether it's looking at a compound-s=
tatement or your new syntax until it sees that there's a ';' mi=
ssing before the '}'. That's a lot of lookahead, and would appl=
y to any statement that starts with a '{' (which is extremely commo=
n).</div>
</div></div></div></blockquote><div><br></div></div><div>Random though: all=
ow anonymous structs, with initializers:</div><div><br></div><div>struct { =
.... } =3D foo();</div><div><br></div><div>and, more generally, support aggr=
egate initialization and assignment from an expression E by calling get<=
N>(E).</div>
<div><br></div><div>(Though this would need some finessing to allow 'au=
to'.)</div><div><div><br></div><blockquote class=3D"gmail_quote" style=
=3D"margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(20=
4,204,204);border-left-style:solid;padding-left:1ex">
<div dir=3D"ltr">
<div class=3D"gmail_extra"><div class=3D"gmail_quote"><div><blockquote clas=
s=3D"gmail_quote" style=3D"margin:0px 0px 0px 0.8ex;border-left-width:1px;b=
order-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"=
><div dir=3D"ltr">
which would be conceptually equivalent to:<br>
<br><span style=3D"font-family:'courier new',monospace">=C2=A0=C2=
=A0=C2=A0 struct __anonymous_t__ {<br>
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 std::tuple_element<0,decltype=
(foo())>::type key;<br>=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 double=
value;<br><br>=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 template<typen=
ame T1,typename T2><br>=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 __anon=
ymous_t__(const std::tuple<T1,T2> &vals) : key(std::get<0>(=
vals)), value(std::get<1>(vals) {}<br>
=C2=A0=C2=A0=C2=A0 } __anonymous_v__ =3D foo();</span><br><br>This way also=
doesn't require any new rules for how types are specified.<br></div><d=
iv><div>
<p></p>
-- <br>
<br>
--- <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" target=3D"_=
blank">std-proposals+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/" target=3D"_blank">http://groups.google.com/a/isocpp.org/gro=
up/std-proposals/</a>.<br>
</div></div></blockquote></div></div><br></div></div>
</blockquote></div></div><br></div></div><div><div>
<p></p>
-- <br>
<br>
--- <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" target=3D"_=
blank">std-proposals+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/" target=3D"_blank">http://groups.google.com/a/isocpp.org/gro=
up/std-proposals/</a>.<br>
</div></div></blockquote></div><br></div></div></div></div></div></div><div=
class=3D"HOEnZb"><div class=3D"h5">
<p></p>
-- <br>
<br>
--- <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" target=3D"_=
blank">std-proposals+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/" target=3D"_blank">http://groups.google.com/a/isocpp.org/gro=
up/std-proposals/</a>.<br>
</div></div></blockquote></div><br></div></div>
<p></p>
-- <br />
<br />
--- <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 />
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 />
--089e0158a82a829d7404f97b2a3a--
.
Author: Matthew Woehlke <mw_triad@users.sourceforge.net>
Date: Mon, 19 May 2014 12:42:08 -0400
Raw View
On 2014-02-27 19:33, leszek.swirski@gmail.com wrote:
> On Thursday, 27 February 2014 18:52:20 UTC, Matthew Woehlke wrote:
>> should we also allow e.g.:
>>
>> (int a, double b) = foo();
>
> I was thinking this too, but I'm a little bit worried about having
> parenthesised expressions as L-values -- I'm not sure how pleased the
> parser people would be about something like this, especially since (a,b) is
> a perfectly valid L-value (and not a tuple unpacking).
Actually... is this even an issue? It seems that a declaration in this
context is currently invalid, ergo as soon as the compiler sees '('
followed by a typename (or at worst, further followed by an identifier),
it could "know" that it is dealing with a tuple unpacking.
(As a bonus, we could also newly permit e.g. '(int a) = expr', where
expr could be a tuple (get<0>) or even an int literal.)
This has the benefit of not introducing a new keyword, not requiring a
keyword to invoke (which itself I think is significant), and being
fairly natural at least to programmers familiar with Python, as ()'s are
used there to denote tuples.
As a fallback, I'd be okay with Richard's suggestion of using <>'s
instead of ()'s.
--
Matthew
--
---
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/.
.
Author: snk_kid <korcan.hussein@googlemail.com>
Date: Mon, 19 May 2014 14:16:48 -0700 (PDT)
Raw View
------=_Part_761_21798955.1400534208742
Content-Type: text/plain; charset=UTF-8
>
> What do people think?
>
I think you've just reinevented pattern matching! which is prevalent in
virtually all statically typed functional programming languages. What
you're describing in particular is just one type of pattern match, a
deconstructing tuple pattern. There are various other kinds of patterns
that I recommend checking it out.
I would love to see general pattern matching support added to C++ in the
future, it's one of the most sorely, *most painfully *missed feature when
I'm coding in C/C++. Trust me when you've been programming in a language
with pattern matching support for a while then go to another without it,
it's painful.
It would make the other thread about "named tuples" completely redundant,
and to me is a hacky solution to begin with. To me pattern matching is the
proper general solution to this and other related problems.
There is a proposal already to bring a tiny subset of pattern matching
abilities to C++, specifically a type-case patterns but I really think we
should just go the whole way for C++17, that would really evolve the
language.
--
---
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_761_21798955.1400534208742
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr"><blockquote class=3D"gmail_quote" style=3D"margin: 0;margi=
n-left: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;"><div dir=3D"l=
tr"><div><font color=3D"#000000" face=3D"arial, sans-serif"></font></div><d=
iv><font color=3D"#000000" face=3D"arial, sans-serif">What do people think?=
</font></div></div></blockquote><div><br>I think you've just reinevented pa=
ttern matching! which is prevalent in virtually all statically typed functi=
onal programming languages. What you're describing in particular is just on=
e type of pattern match, a deconstructing tuple pattern. There are various =
other kinds of patterns that I recommend checking it out.<br><br>I would lo=
ve to see general pattern matching support added to C++ in the future, it's=
one of the most sorely, <b>most painfully </b>missed feature when I'm codi=
ng in C/C++. Trust me when you've been programming in a language with patte=
rn matching support for a while then go to another without it, it's painful=
..<br><br>It would make the other thread about "named tuples" completely red=
undant, and to me is a hacky solution to begin with. To me pattern matching=
is the proper general solution to this and other related problems.<br><br>=
There is a proposal already to bring a tiny subset of pattern matching abil=
ities to C++, specifically a type-case patterns but I really think we shoul=
d just go the whole way for C++17, that would really evolve the language.<b=
r><br></div></div>
<p></p>
-- <br />
<br />
--- <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 />
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/">http://groups.google.com/a/isocpp.org/group/std-proposals/<=
/a>.<br />
------=_Part_761_21798955.1400534208742--
.
Author: gmisocpp@gmail.com
Date: Mon, 19 May 2014 15:03:12 -0700 (PDT)
Raw View
------=_Part_3866_23618417.1400536992721
Content-Type: text/plain; charset=UTF-8
Hi
On Tuesday, May 20, 2014 9:16:48 AM UTC+12, snk_kid wrote:
>
> What do people think?
>>
>
> I think you've just reinevented pattern matching! which is prevalent in
> virtually all statically typed functional programming languages. What
> you're describing in particular is just one type of pattern match, a
> deconstructing tuple pattern. There are various other kinds of patterns
> that I recommend checking it out.
>
> I would love to see general pattern matching support added to C++ in the
> future, it's one of the most sorely, *most painfully *missed feature when
> I'm coding in C/C++. Trust me when you've been programming in a language
> with pattern matching support for a while then go to another without it,
> it's painful.
>
> It would make the other thread about "named tuples" completely redundant,
> and to me is a hacky solution to begin with. To me pattern matching is the
> proper general solution to this and other related problems.
>
> There is a proposal already to bring a tiny subset of pattern matching
> abilities to C++, specifically a type-case patterns but I really think we
> should just go the whole way for C++17, that would really evolve the
> language.
>
>
Yes I was saying on the named tuple thread, that a more expanded set of
tools is needed than just adding a name to a tuple. I'm pleased this thread
has popped up that seems to be getting into those things. The discussion
needed to be more wide ranging than it was before now it is so I'm pleased
about that.
--
---
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_3866_23618417.1400536992721
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr">Hi<br><br>On Tuesday, May 20, 2014 9:16:48 AM UTC+12, snk_=
kid wrote:<blockquote class=3D"gmail_quote" style=3D"margin: 0px 0px 0px 0.=
8ex; padding-left: 1ex; border-left-color: rgb(204, 204, 204); border-left-=
width: 1px; border-left-style: solid;"><div dir=3D"ltr"><blockquote class=
=3D"gmail_quote" style=3D"margin: 0px 0px 0px 0.8ex; padding-left: 1ex; bor=
der-left-color: rgb(204, 204, 204); border-left-width: 1px; border-left-sty=
le: solid;"><div dir=3D"ltr"><div><font color=3D"#000000" face=3D"arial, sa=
ns-serif"></font></div><div><font color=3D"#000000" face=3D"arial, sans-ser=
if">What do people think?</font></div></div></blockquote><div><br>I think y=
ou've just reinevented pattern matching! which is prevalent in virtually al=
l statically typed functional programming languages. What you're describing=
in particular is just one type of pattern match, a deconstructing tuple pa=
ttern. There are various other kinds of patterns that I recommend checking =
it out.<br><br>I would love to see general pattern matching support added t=
o C++ in the future, it's one of the most sorely, <b>most painfully </b>mis=
sed feature when I'm coding in C/C++. Trust me when you've been programming=
in a language with pattern matching support for a while then go to another=
without it, it's painful.<br><br>It would make the other thread about "nam=
ed tuples" completely redundant, and to me is a hacky solution to begin wit=
h. To me pattern matching is the proper general solution to this and other =
related problems.<br></div></div></blockquote><div><br></div><blockquote cl=
ass=3D"gmail_quote" style=3D"margin: 0px 0px 0px 0.8ex; padding-left: 1ex; =
border-left-color: rgb(204, 204, 204); border-left-width: 1px; border-left-=
style: solid;"><div dir=3D"ltr"><div><br>There is a proposal already to bri=
ng a tiny subset of pattern matching abilities to C++, specifically a type-=
case patterns but I really think we should just go the whole way for C++17,=
that would really evolve the language.<br><br></div></div></blockquote><di=
v><br></div><div>Yes I was saying on the named tuple thread, that =
;a more expanded set of tools is needed than just adding a name to a tuple.=
I'm pleased this thread has popped up that seems to be getting i=
nto those things. The discussion needed to be more wide ranging&n=
bsp;than it was before now it is so I'm pleased about that.</div></div=
>
<p></p>
-- <br />
<br />
--- <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 />
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/">http://groups.google.com/a/isocpp.org/group/std-proposals/<=
/a>.<br />
------=_Part_3866_23618417.1400536992721--
.
Author: "'Geoffrey Romer' via ISO C++ Standard - Future Proposals" <std-proposals@isocpp.org>
Date: Mon, 19 May 2014 15:41:08 -0700
Raw View
--089e015386a29fa43004f9c875cb
Content-Type: text/plain; charset=UTF-8
On Mon, May 19, 2014 at 2:16 PM, snk_kid <korcan.hussein@googlemail.com>wrote:
> What do people think?
>>
>
> I think you've just reinevented pattern matching! which is prevalent in
> virtually all statically typed functional programming languages. What
> you're describing in particular is just one type of pattern match, a
> deconstructing tuple pattern. There are various other kinds of patterns
> that I recommend checking it out.
>
> I would love to see general pattern matching support added to C++ in the
> future, it's one of the most sorely, *most painfully *missed feature when
> I'm coding in C/C++. Trust me when you've been programming in a language
> with pattern matching support for a while then go to another without it,
> it's painful.
>
> It would make the other thread about "named tuples" completely redundant,
> and to me is a hacky solution to begin with. To me pattern matching is the
> proper general solution to this and other related problems.
>
> There is a proposal already to bring a tiny subset of pattern matching
> abilities to C++, specifically a type-case patterns but I really think we
> should just go the whole way for C++17, that would really evolve the
> language.
>
I'm a fan of functional-style pattern matching, and frequently find myself
wishing for it in C++, but there's certainly no "just" about it; it's not
at all clear what pattern matching in C++ would even look like, much less
what would constitute "the whole way" as opposed to part-way. What would be
the syntax for patterns? How would the language select a matching pattern
for a call, and populate the pattern variables? Could user-defined types
participate in pattern-matching, other than as leaf variables? If so, how
would the semantics be specified?
By the way, can you provide a link to the type-case patterns proposal you
refer to?
>
> --
>
> ---
> 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/.
>
--
---
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/.
--089e015386a29fa43004f9c875cb
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr"><div class=3D"gmail_extra"><br></div><div class=3D"gmail_e=
xtra"><div class=3D"gmail_quote">On Mon, May 19, 2014 at 2:16 PM, snk_kid <=
span dir=3D"ltr"><<a href=3D"mailto:korcan.hussein@googlemail.com" targe=
t=3D"_blank">korcan.hussein@googlemail.com</a>></span> wrote:<br>
<blockquote class=3D"gmail_quote" style=3D"margin:0px 0px 0px 0.8ex;border-=
left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;p=
adding-left:1ex"><div dir=3D"ltr"><blockquote class=3D"gmail_quote" style=
=3D"margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(20=
4,204,204);border-left-style:solid;padding-left:1ex">
<div dir=3D"ltr"><div><font color=3D"#000000" face=3D"arial, sans-serif"></=
font></div><div><font color=3D"#000000" face=3D"arial, sans-serif">What do =
people think?</font></div></div></blockquote><div><br>I think you've ju=
st reinevented pattern matching! which is prevalent in virtually all static=
ally typed functional programming languages. What you're describing in =
particular is just one type of pattern match, a deconstructing tuple patter=
n. There are various other kinds of patterns that I recommend checking it o=
ut.<br>
<br>I would love to see general pattern matching support added to C++ in th=
e future, it's one of the most sorely, <b>most painfully </b>missed fea=
ture when I'm coding in C/C++. Trust me when you've been programmin=
g in a language with pattern matching support for a while then go to anothe=
r without it, it's painful.<br>
<br>It would make the other thread about "named tuples" completel=
y redundant, and to me is a hacky solution to begin with. To me pattern mat=
ching is the proper general solution to this and other related problems.<br=
>
<br>There is a proposal already to bring a tiny subset of pattern matching =
abilities to C++, specifically a type-case patterns but I really think we s=
hould just go the whole way for C++17, that would really evolve the languag=
e.=C2=A0</div>
</div></blockquote><div><br></div><div>I'm a fan of functional-style pa=
ttern matching, and frequently find myself wishing for it in C++, but there=
's certainly no "just" about it; it's not at all clear wh=
at pattern matching in C++ would even look like, much less what would const=
itute "the whole way" as opposed to part-way. What would be the s=
yntax for patterns? How would the language select a matching pattern for a =
call, and populate the pattern variables? Could user-defined types particip=
ate in pattern-matching, other than as leaf variables? If so, how would the=
semantics be specified?</div>
<div><br></div><div>By the way, can you provide a link to the type-case pat=
terns proposal you refer to?</div><div>=C2=A0</div><blockquote class=3D"gma=
il_quote" style=3D"margin:0px 0px 0px 0.8ex;border-left-width:1px;border-le=
ft-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
<div dir=3D"ltr"><div><br></div></div><div class=3D""><div class=3D"h5">
<p></p>
-- <br>
<br>
--- <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" target=3D"_=
blank">std-proposals+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/" target=3D"_blank">http://groups.google.com/a/isocpp.org/gro=
up/std-proposals/</a>.<br>
</div></div></blockquote></div><br></div></div>
<p></p>
-- <br />
<br />
--- <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 />
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 />
--089e015386a29fa43004f9c875cb--
.
Author: Ville Voutilainen <ville.voutilainen@gmail.com>
Date: Tue, 20 May 2014 01:43:18 +0300
Raw View
On 20 May 2014 01:41, 'Geoffrey Romer' via ISO C++ Standard - Future
Proposals > I'm a fan of functional-style pattern matching, and
frequently find myself
> wishing for it in C++, but there's certainly no "just" about it; it's not at
> all clear what pattern matching in C++ would even look like, much less what
> would constitute "the whole way" as opposed to part-way. What would be the
> syntax for patterns? How would the language select a matching pattern for a
> call, and populate the pattern variables? Could user-defined types
> participate in pattern-matching, other than as leaf variables? If so, how
> would the semantics be specified?
>
> By the way, can you provide a link to the type-case patterns proposal you
> refer to?
My _guess_ would be that it's this one:
http://open-std.org/JTC1/SC22/WG21/docs/papers/2012/n3449.pdf
This might also be of interest:
http://www.stroustrup.com/OpenPatternMatching.pdf
--
---
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/.
.
Author: Douglas Boffey <douglas.boffey@gmail.com>
Date: Wed, 21 May 2014 06:48:22 -0700 (PDT)
Raw View
------=_Part_2154_19119586.1400680102973
Content-Type: text/plain; charset=UTF-8
>
>
> < A a, B b > = s;
>
Would you also allow
<A a, B b>=s;
(i.e. greater-or-equal instead of greater-than followed by equal-to)?
--
---
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_2154_19119586.1400680102973
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr"><blockquote style=3D"margin: 0px 0px 0px 0.8ex; padding-le=
ft: 1ex; border-left-color: rgb(204, 204, 204); border-left-width: 1px; bor=
der-left-style: solid;" class=3D"gmail_quote"><div dir=3D"ltr"><div><div cl=
ass=3D"gmail_quote"><div> </div><div>< A a, B b > =3D s;</div></=
div></div></div></blockquote><div> </div><div>Would you also allow&nbs=
p;</div><div> </div><div> <A a, B b>=3Ds;</div><div> =
</div><div>(i.e. greater-or-equal instead of greater-than followed by equal=
-to)? </div></div>
<p></p>
-- <br />
<br />
--- <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 />
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/">http://groups.google.com/a/isocpp.org/group/std-proposals/<=
/a>.<br />
------=_Part_2154_19119586.1400680102973--
.
Author: leszek.swirski@gmail.com
Date: Thu, 22 May 2014 10:12:36 -0700 (PDT)
Raw View
------=_Part_574_10365268.1400778756816
Content-Type: text/plain; charset=UTF-8
On Monday, 19 May 2014 23:41:08 UTC+1, Geoffrey Romer wrote:
>
> I'm a fan of functional-style pattern matching, and frequently find myself
> wishing for it in C++, but there's certainly no "just" about it; it's not
> at all clear what pattern matching in C++ would even look like, much less
> what would constitute "the whole way" as opposed to part-way. What would be
> the syntax for patterns? How would the language select a matching pattern
> for a call, and populate the pattern variables? Could user-defined types
> participate in pattern-matching, other than as leaf variables? If so, how
> would the semantics be specified?
>
I agree that "just" is inappropriate here. In my mind, there are two
elements to pattern matching; switching based on pattern, as in the
type-casing example, and deconstructing based on pattern. Although these
are both applications of pattern matching in a very general sense, I feel
that they are almost entirely distinct from a semantic point of view:
pattern-based switching is a form of multiple dispatch (something like
"runtime overloading"), while pattern-based deconstruction is used for
assignment to L-values.
Now, in a nice functional language like SML, we can conflate the two into
very elegant syntax, mostly because all it really supports is primitive
types, tuples and tagged unions (algebraic types). Then, the
pattern-matching (both for switching and deconstructing) looks the same as
constructing the type. However, once you start having more complex types,
or rather, classes and objects, this starts to break down. This is why
Python and Clojure have the two as separate features: deconstructing
becomes tuple unpacking (Python) or destructing (Clojure), while switching
becomes multimethods (as function decorators in Python or
defmulti/defmethod in Clojure). Both of these happen to allow decontruction
in their multimethods just by virtue of having deconstruction of any
function parameters, but the two types of pattern-matching are still
separate beasts.
So, with that in mind, I can't imagine what general pattern-matching would
look like in C++; I can't even think of what general deconstructing pattern
matching would look like; naturally, the constructor-like syntax that SML
uses is not suitable in C++. My original proposal was based on
Python/Clojure style tuple-only deconstructing pattern matching, because
that's a) what I miss the most, and b) the best I could think of with
minimal syntax/semantics changes to C++.
--
---
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_574_10365268.1400778756816
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr">On Monday, 19 May 2014 23:41:08 UTC+1, Geoffrey Romer wro=
te:<blockquote class=3D"gmail_quote" style=3D"margin: 0;margin-left: 0.8ex;=
border-left: 1px #ccc solid;padding-left: 1ex;"><div dir=3D"ltr"><div class=
=3D"gmail_quote"><div>I'm a fan of functional-style pattern matching, and f=
requently find myself wishing for it in C++, but there's certainly no "just=
" about it; it's not at all clear what pattern matching in C++ would even l=
ook like, much less what would constitute "the whole way" as opposed to par=
t-way. What would be the syntax for patterns? How would the language select=
a matching pattern for a call, and populate the pattern variables? Could u=
ser-defined types participate in pattern-matching, other than as leaf varia=
bles? If so, how would the semantics be specified?</div></div></div></block=
quote><div><br></div><div style=3D"font-family: arial, sans-serif;">I agree=
that "just" is inappropriate here. In my mind, there are two elements to p=
attern matching; switching based on pattern, as in the type-casing example,=
and deconstructing based on pattern. Although these are both applications =
of pattern matching in a very general sense, I feel that they are almost en=
tirely distinct from a semantic point of view: pattern-based switching is a=
form of multiple dispatch (something like "runtime overloading"), while pa=
ttern-based deconstruction is used for assignment to L-values.</div><div st=
yle=3D"font-family: arial, sans-serif;"><br></div><div style=3D"font-family=
: arial, sans-serif;">Now, in a nice functional language like SML, we can c=
onflate the two into very elegant syntax, mostly because all it really supp=
orts is primitive types, tuples and tagged unions (algebraic types). Then, =
the pattern-matching (both for switching and deconstructing) looks the same=
as constructing the type. However, once you start having more complex type=
s, or rather, classes and objects, this starts to break down. This is why P=
ython and Clojure have the two as separate features: deconstructing becomes=
tuple unpacking (Python) or destructing (Clojure), while switching becomes=
multimethods (as function decorators in Python or defmulti/defmethod =
in Clojure). Both of these happen to allow decontruction in their multimeth=
ods just by virtue of having deconstruction of any function parameters, but=
the two types of pattern-matching are still separate beasts.</div><div sty=
le=3D"font-family: arial, sans-serif;"><br></div><div><span style=3D"font-f=
amily: arial, sans-serif;">So, with that in mind, I can't imagine what gene=
ral pattern-matching would look like in C++; I can't even think of what gen=
eral deconstructing pattern matching would look like; naturally, the constr=
uctor-like syntax that SML uses is not suitable in C++. My original proposa=
l was based on Python/Clojure style tuple-only deconstructing pattern match=
ing, because that's a) what I miss the most, and b) the best I could think =
of with minimal syntax/semantics changes to C++.</span> </div></div>
<p></p>
-- <br />
<br />
--- <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 />
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/">http://groups.google.com/a/isocpp.org/group/std-proposals/<=
/a>.<br />
------=_Part_574_10365268.1400778756816--
.
Author: leszek.swirski@gmail.com
Date: Thu, 22 May 2014 10:23:32 -0700 (PDT)
Raw View
------=_Part_598_27621112.1400779412481
Content-Type: text/plain; charset=UTF-8
On Monday, 19 May 2014 17:42:08 UTC+1, Matthew Woehlke wrote:
>
> On 2014-02-27 19:33, leszek....@gmail.com <javascript:> wrote:
> > On Thursday, 27 February 2014 18:52:20 UTC, Matthew Woehlke wrote:
> >> should we also allow e.g.:
> >>
> >> (int a, double b) = foo();
> >
> > I was thinking this too, but I'm a little bit worried about having
> > parenthesised expressions as L-values -- I'm not sure how pleased the
> > parser people would be about something like this, especially since (a,b)
> is
> > a perfectly valid L-value (and not a tuple unpacking).
>
> Actually... is this even an issue? It seems that a declaration in this
> context is currently invalid, ergo as soon as the compiler sees '('
> followed by a typename (or at worst, further followed by an identifier),
> it could "know" that it is dealing with a tuple unpacking.
>
Sure, but this starts being very context-dependent lookahead, I'm not sure
how compiler-friendly that is.
Also, I'm not convinced that
(auto a, auto b) = f();
is more readable than
auto (a, b) = f();
although perhaps allowing
(int a, double b) = f();
in preference to
auto (int a, double b) = f();
is worth it.
(As a bonus, we could also newly permit e.g. '(int a) = expr', where
> expr could be a tuple (get<0>) or even an int literal.)
>
Thumbs up from me on allowing single element tuples in the syntax.
As a fallback, I'd be okay with Richard's suggestion of using <>'s
> instead of ()'s.
>
I'm wary of <>'s simply because they look more like template definitions
than something to do with assignment, plus Douglas's parsing ambiguity
(let's not have the >> mess all over again). Though I don't have a strong
opinion here.
--
---
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_598_27621112.1400779412481
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr">On Monday, 19 May 2014 17:42:08 UTC+1, Matthew Woehlke wr=
ote:<blockquote class=3D"gmail_quote" style=3D"margin: 0;margin-left: 0.8ex=
;border-left: 1px #ccc solid;padding-left: 1ex;">On 2014-02-27 19:33, <a hr=
ef=3D"javascript:" target=3D"_blank" gdf-obfuscated-mailto=3D"Ev_5aZ7GiAcJ"=
onmousedown=3D"this.href=3D'javascript:';return true;" onclick=3D"this.hre=
f=3D'javascript:';return true;">leszek....@gmail.com</a> wrote:
<br>> On Thursday, 27 February 2014 18:52:20 UTC, Matthew Woehlke wrote:
<br>>> should we also allow e.g.:=20
<br>>>
<br>>> (int a, double b) =3D foo();=20
<br>>=20
<br>> I was thinking this too, but I'm a little bit worried about having=
=20
<br>> parenthesised expressions as L-values -- I'm not sure how pleased =
the=20
<br>> parser people would be about something like this, especially since=
(a,b) is=20
<br>> a perfectly valid L-value (and not a tuple unpacking).
<br>
<br>Actually... is this even an issue? It seems that a declaration in this
<br>context is currently invalid, ergo as soon as the compiler sees '('
<br>followed by a typename (or at worst, further followed by an identifier)=
,
<br>it could "know" that it is dealing with a tuple unpacking.
<br></blockquote><div><br></div><div>Sure, but this starts being very conte=
xt-dependent lookahead, I'm not sure how compiler-friendly that is.</div><d=
iv><br></div><div>Also, I'm not convinced that</div><div> (aut=
o a, auto b) =3D f();</div><div>is more readable than</div> au=
to (a, b) =3D f();<div>although perhaps allowing</div><div> (i=
nt a, double b) =3D f();</div><div>in preference to</div><div> =
auto (int a, double b) =3D f();<br><div>is worth it. </div><div><br><=
/div><blockquote class=3D"gmail_quote" style=3D"margin: 0;margin-left: 0.8e=
x;border-left: 1px #ccc solid;padding-left: 1ex;">(As a bonus, we could als=
o newly permit e.g. '(int a) =3D expr', where
<br>expr could be a tuple (get<0>) or even an int literal.)
<br></blockquote><div><br></div><div>Thumbs up from me on allowing single e=
lement tuples in the syntax.</div><div><br></div><blockquote class=3D"gmail=
_quote" style=3D"margin: 0;margin-left: 0.8ex;border-left: 1px #ccc solid;p=
adding-left: 1ex;">As a fallback, I'd be okay with Richard's suggestion of =
using <>'s
<br>instead of ()'s.
<br></blockquote><div><br></div><div>I'm wary of <>'s simply because =
they look more like template definitions than something to do with assignme=
nt, plus Douglas's parsing ambiguity (let's not have the >> mess all =
over again). Though I don't have a strong opinion here.</div></div></div>
<p></p>
-- <br />
<br />
--- <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 />
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/">http://groups.google.com/a/isocpp.org/group/std-proposals/<=
/a>.<br />
------=_Part_598_27621112.1400779412481--
.
Author: Matthew Woehlke <mw_triad@users.sourceforge.net>
Date: Thu, 22 May 2014 13:51:03 -0400
Raw View
On 2014-05-22 13:23, leszek.swirski@gmail.com wrote:
> On Monday, 19 May 2014 17:42:08 UTC+1, Matthew Woehlke wrote:
>>
>> On 2014-02-27 19:33, leszek....@gmail.com <javascript:> wrote:
>>> On Thursday, 27 February 2014 18:52:20 UTC, Matthew Woehlke wrote:
>>>> should we also allow e.g.:
>>>>
>>>> (int a, double b) = foo();
>>>
>>> I was thinking this too, but I'm a little bit worried about having
>>> parenthesised expressions as L-values -- I'm not sure how pleased the
>>> parser people would be about something like this, especially since (a,b)
>> is
>>> a perfectly valid L-value (and not a tuple unpacking).
>>
>> Actually... is this even an issue? It seems that a declaration in this
>> context is currently invalid, ergo as soon as the compiler sees '('
>> followed by a typename (or at worst, further followed by an identifier),
>> it could "know" that it is dealing with a tuple unpacking.
>>
>
> Sure, but this starts being very context-dependent lookahead, I'm not sure
> how compiler-friendly that is.
What's to look ahead? When you see a '(', set a 'might be tuple
unpacking' flag and get on with parsing. If you end up seeing what looks
like a declaration, check the flag. It can be done with state rather
than look-ahead (no more look-ahead than is needed for declarations
anyway, I think).
> Also, I'm not convinced that
> (auto a, auto b) = f();
> is more readable than
> auto (a, b) = f();
It isn't, but...
> although perhaps allowing
> (int a, double b) = f();
....I'd allow it for the case of non-matching explicit types (i.e. this).
> in preference to
> auto (int a, double b) = f();
> is worth it.
This makes no sense... 'auto int a = f()'? We're back to 'auto' being a
storage specifier and not a type. Or something...
>> As a fallback, I'd be okay with Richard's suggestion of using <>'s
>> instead of ()'s.
>
> I'm wary of <>'s simply because they look more like template definitions
> than something to do with assignment, plus Douglas's parsing ambiguity
> (let's not have the >> mess all over again). Though I don't have a strong
> opinion here.
Sure. I'd prefer ()'s also. Just that I'd rather have <>'s than not have
the feature at all :-).
--
Matthew
--
---
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/.
.
Author: leszek.swirski@gmail.com
Date: Wed, 28 May 2014 11:19:30 -0700 (PDT)
Raw View
------=_Part_2310_11578358.1401301170974
Content-Type: text/plain; charset=UTF-8
On Thursday, 22 May 2014 18:51:03 UTC+1, Matthew Woehlke wrote:
>
> > Sure, but this starts being very context-dependent lookahead, I'm not
> sure
> > how compiler-friendly that is.
>
> What's to look ahead? When you see a '(', set a 'might be tuple
> unpacking' flag and get on with parsing. If you end up seeing what looks
> like a declaration, check the flag. It can be done with state rather
> than look-ahead (no more look-ahead than is needed for declarations
> anyway, I think).
>
Sounds plausible, I'm just being careful. Hence "not sure" rather than
"it's not". I might post a message on the clang mailing list asking their
opinion.
> Also, I'm not convinced that
> > (auto a, auto b) = f();
> > is more readable than
> > auto (a, b) = f();
>
> It isn't, but I'd allow it for the case of non-matching explicit types.
True, but I'm trying to optimise for the common case. The whole point here
is to decrease syntax noise, and so I'd be tempted to keep `auto (a, b) =
f()` and disallow explicit types entirely. My justification for this is
that you'd only want explicit types if you:
a) want to be explicit about return types, in which case you're better
off being explicit about the fact the what is actually returned is a tuple
(and you won't be happy about the direction that C++ is going in); or
b) want to convert types, in which case you're better off doing this
explicitly rather than implicitly:
auto (a, b) = f();
double b2 = b; // or even auto b2 = double(b); if you're so
inclined
Sure. I'd prefer ()'s also. Just that I'd rather have <>'s than not have
> the feature at all :-).
Agreed, which is why I'm not expressing a strong opinion on this 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.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposals/.
------=_Part_2310_11578358.1401301170974
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr">On Thursday, 22 May 2014 18:51:03 UTC+1, Matthew Woehlke =
wrote:<blockquote class=3D"gmail_quote" style=3D"margin: 0;margin-left: 0.8=
ex;border-left: 1px #ccc solid;padding-left: 1ex;">> Sure, but this star=
ts being very context-dependent lookahead, I'm not sure=20
<br>> how compiler-friendly that is.
<br>
<br>What's to look ahead? When you see a '(', set a 'might be tuple
<br>unpacking' flag and get on with parsing. If you end up seeing what look=
s
<br>like a declaration, check the flag. It can be done with state rather
<br>than look-ahead (no more look-ahead than is needed for declarations
<br>anyway, I think).
<br></blockquote><div><br></div><div>Sounds plausible, I'm just being caref=
ul. Hence "not sure" rather than "it's not". I might post a message on the =
clang mailing list asking their opinion.</div><div> </div><div><br></d=
iv><blockquote class=3D"gmail_quote" style=3D"margin: 0;margin-left: 0.8ex;=
border-left: 1px #ccc solid;padding-left: 1ex;">> Also, I'm not convince=
d that
<br>> (auto a, auto b) =3D f();
<br>> is more readable than
<br>> auto (a, b) =3D f();
<br>
<br>It isn't, but I'd allow it for the case of non-matching explicit t=
ypes.</blockquote><div><br></div><div>True, but I'm trying to optimise for =
the common case. The whole point here is to decrease syntax noise, and so I=
'd be tempted to keep `auto (a, b) =3D f()` and disallow explicit types ent=
irely. My justification for this is that you'd only want explicit types if =
you:</div><div> a) want to be explicit about return types, in which c=
ase you're better off being explicit about the fact the what is actually re=
turned is a tuple (and you won't be happy about the direction that C++ is g=
oing in); or</div><div> b) want to convert types, in which case you'r=
e better off doing this explicitly rather than implicitly:</div><div> =
auto (a, b) =3D f(); </div><div> double b2 =3D b;=
// or even auto b2 =3D double(b); if you're so incline=
d</div><div> </div><div><br></div><blockquote class=3D"gmail_quote" st=
yle=3D"margin: 0;margin-left: 0.8ex;border-left: 1px #ccc solid;padding-lef=
t: 1ex;">Sure. I'd prefer ()'s also. Just that I'd rather have <>'s t=
han not have
<br>the feature at all :-).
</blockquote><div><br></div><div>Agreed, which is why I'm not expressing a =
strong opinion on this point!</div></div>
<p></p>
-- <br />
<br />
--- <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 />
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/">http://groups.google.com/a/isocpp.org/group/std-proposals/<=
/a>.<br />
------=_Part_2310_11578358.1401301170974--
.
Author: Bengt Gustafsson <bengt.gustafsson@beamways.com>
Date: Wed, 28 May 2014 15:16:26 -0700 (PDT)
Raw View
------=_Part_56_9099882.1401315386472
Content-Type: text/plain; charset=UTF-8
I think that what we are looking for here is something like "reverse"
initializers. Currently we can construct a POD struct and more with a set
of values in { } braces for instance:
struct Point {
int x;
int y;
};
Point p{1,2};
But we can't do the reverse:
{int x, int y} = p;
If we could do this, the function return case follows immediately (e.g. in
this case for a function returning a Point, or anything else where the two
first "members" can be converted to int).
However, there are a few issues with the above syntax, some of which have
been pointed out, such as parsing and the uncertainty of the scope of the x
and y. A third issue I haven't seen discussed is the case of
a mix of declarations and preexisting variables on the left of =.
To resolve this it would be possible to use this syntax:
inline { int x, int y} = p;
Here the word inline is used to indicate that the scope of x and y is
extended beyond their own little useless {} pair. It also clarifies to the
parser that this is a unpacking/destructing/whatever construct without
undue look ahead. Finally it would be perfectly possible to allow any mix
of preexisting and new variables and auto:
int y;
inline { auto x, y } = p;
I used comma separation above to make it syntactically closer to an
initializer but maybe that was not so wise as if you look at the last
example it seems that we have two auto variables x, y while my intention
was that y was the previously declared variable. On the other hand, if
semicolon was used it would not be consistent with an initializer. The idea
with associating it with an initializer is that we could use the same rule
set when it comes to how lhs and rhs elements match up and how nesting
could be allowed.
I think this can be elaborated further to reach some kind of common ground.
And maybe we would do better disregarding parsing problems and get rid of
the 'inline' or auto and demand that parsing a {} with a trailing = be
treated as an unpacking clause. That should not be so hard to do in
practice. Much easier than passing the body of an inline function in the
class head, that's for sure!
--
---
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_56_9099882.1401315386472
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr">I think that what we are looking for here is something lik=
e "reverse" initializers. Currently we can construct a POD struct and more =
with a set of values in { } braces for instance:<div><br></div><div>struct =
Point {</div><div> int x;</div><div> int y;</div><div>};</div><=
div><br></div><div>Point p{1,2};</div><div><br></div><div>But we can't do t=
he reverse:</div><div><br></div><div>{int x, int y} =3D p;</div><div><br></=
div><div>If we could do this, the function return case follows immediately =
(e.g. in this case for a function returning a Point, or anything else where=
the two first "members" can be converted to int).</div><div><br></div><div=
>However, there are a few issues with the above syntax, some of which have =
been pointed out, such as parsing and the uncertainty of the scope of the x=
and y. A third issue I haven't seen discussed is the case of</div><div>a m=
ix of declarations and preexisting variables on the left of =3D.</div><div>=
<br></div><div>To resolve this it would be possible to use this syntax:</di=
v><div><br></div><div>inline { int x, int y} =3D p;</div><div><br></div><di=
v>Here the word inline is used to indicate that the scope of x and y is ext=
ended beyond their own little useless {} pair. It also clarifies to the par=
ser that this is a unpacking/destructing/whatever construct without undue l=
ook ahead. Finally it would be perfectly possible to allow any mix of preex=
isting and new variables and auto:</div><div><br></div><div>int y;</div><di=
v>inline { auto x, y } =3D p;</div><div><br></div><div>I used comma separat=
ion above to make it syntactically closer to an initializer but maybe that =
was not so wise as if you look at the last example it seems that we have tw=
o auto variables x, y while my intention was that y was the previously decl=
ared variable. On the other hand, if semicolon was used it would not be con=
sistent with an initializer. The idea with associating it with an initializ=
er is that we could use the same rule set when it comes to how lhs and rhs =
elements match up and how nesting could be allowed.</div><div><br></div><di=
v>I think this can be elaborated further to reach some kind of common groun=
d. And maybe we would do better disregarding parsing problems and get rid o=
f the 'inline' or auto and demand that parsing a {} with a trailing =3D be =
treated as an unpacking clause. That should not be so hard to do in practic=
e. Much easier than passing the body of an inline function in the class hea=
d, that's for sure!</div></div>
<p></p>
-- <br />
<br />
--- <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 />
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/">http://groups.google.com/a/isocpp.org/group/std-proposals/<=
/a>.<br />
------=_Part_56_9099882.1401315386472--
.
Author: gadelan@gmail.com
Date: Fri, 30 May 2014 09:46:36 -0700 (PDT)
Raw View
------=_Part_400_22942437.1401468396594
Content-Type: text/plain; charset=UTF-8
>
> I think that what we are looking for here is something like "reverse"
> initializers.
>
This made me remember Scala and its unapply() methods. See
http://lampwww.epfl.ch/~emir/written/MatchingObjectsWithPatterns-TR.pdf
section 4 Extractors if you are curious.
--
---
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_400_22942437.1401468396594
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr"><blockquote class=3D"gmail_quote" style=3D"margin: 0;margi=
n-left: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;"><div dir=3D"l=
tr">I think that what we are looking for here is something like "reverse" i=
nitializers.</div></blockquote><div><br></div><div>This made me remember Sc=
ala and its unapply() methods. See http://lampwww.epfl.ch/~emir/writt=
en/MatchingObjectsWithPatterns-TR.pdf section 4 Extractors if you are=
curious.</div></div>
<p></p>
-- <br />
<br />
--- <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 />
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/">http://groups.google.com/a/isocpp.org/group/std-proposals/<=
/a>.<br />
------=_Part_400_22942437.1401468396594--
.
Author: walter1234 <walter2bz@gmail.com>
Date: Sun, 15 Jun 2014 05:07:49 -0700 (PDT)
Raw View
------=_Part_522_11872016.1402834069082
Content-Type: text/plain; charset=UTF-8
Something related, would it be possible to retrofit swifts .0 , .1 ..
syntax for tuple member access into C++?
I think I'd rather have that than destructuring sugar.
perhaps those could be synonymous for accessing struct elements by index.
c++ does know the order of struct elements, right, since you can use the
order with an initialiser list.
(on another note, i'm very surprised the std lib doesn't use a
structKeyValue{.. key, .. value} in various contexts with std::map , that
would be clearer than using tuples in that instance)
--
---
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_522_11872016.1402834069082
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr"><div>Something related, would it be possible to retrofit s=
wifts .0 , .1 .. syntax for tuple member access into C++?</div><div>I think=
I'd rather have that than destructuring sugar.<br></div><div><br></div><di=
v>perhaps those could be synonymous for accessing struct elements by index.=
</div><div>c++ does know the order of struct elements, right, since y=
ou can use the order with an initialiser list.</div><div><br></div><div>(on=
another note, i'm very surprised the std lib doesn't use a structKey=
Value{.. key, .. value} in various contexts with std::map , that would be c=
learer than using tuples in that instance)</div><div><br></div><div><br></d=
iv></div>
<p></p>
-- <br />
<br />
--- <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 />
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/">http://groups.google.com/a/isocpp.org/group/std-proposals/<=
/a>.<br />
------=_Part_522_11872016.1402834069082--
.
Author: leszek.swirski@gmail.com
Date: Mon, 28 Jul 2014 02:37:57 -0700 (PDT)
Raw View
------=_Part_199_621786889.1406540277743
Content-Type: text/plain; charset=UTF-8
>
> Something related, would it be possible to retrofit swifts .0 , .1 ..
> syntax for tuple member access into C++?
>
I really like that idea, especially since get<0>(x) is so verbose...
> I think I'd rather have that than destructuring sugar.
>
.... but I'd rather have it "in addition to" destructuring sugar.
inline { int x, int y} = p;
>
This is elegant in both reuse of keywords, and this idea of reverse
initializers, but my issue with it is the increased verbosity; after all,
the whole point of this proposal is to have a short and handy sugar syntax
for getting at the unknown-type (or rather "I-don't-care"-type) elements of
a tuple.
A third issue I haven't seen discussed is the case of a mix of declarations
> and preexisting variables on the left of =.
>
I don't think this is a problem. Since the destructuring is just sugar, I
think it doesn't need to handle more complex cases such as this one; for
those, there's always manual unpacking with get<n>() or std::tie.
--
---
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_199_621786889.1406540277743
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr"><blockquote class=3D"gmail_quote" style=3D"margin: 0;margi=
n-left: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;"><div dir=3D"l=
tr"><div>Something related, would it be possible to retrofit swifts .0 , .1=
.. syntax for tuple member access into C++?</div></div></blockquote><div><=
br></div><div>I really like that idea, especially since get<0>(x) is =
so verbose...</div><div> </div><blockquote class=3D"gmail_quote" style=
=3D"margin: 0;margin-left: 0.8ex;border-left: 1px #ccc solid;padding-left: =
1ex;"><div dir=3D"ltr"><div>I think I'd rather have that than destructuring=
sugar.<br></div></div></blockquote><div><br></div><div>... but I'd rather =
have it "in addition to" destructuring sugar.</div><div><br></div><div><br>=
</div><div><div dir=3D"ltr"><blockquote class=3D"gmail_quote" style=3D"marg=
in: 0px 0px 0px 0.8ex; border-left-width: 1px; border-left-color: rgb(204, =
204, 204); border-left-style: solid; padding-left: 1ex;">inline { int x, in=
t y} =3D p;<br></blockquote><div><br></div><div>This is elegant in both reu=
se of keywords, and this idea of reverse initializers, but my issue with it=
is the increased verbosity; after all, the whole point of this proposal is=
to have a short and handy sugar syntax for getting at the unknown-type (or=
rather "I-don't-care"-type) elements of a tuple.</div><div><br></div><bloc=
kquote class=3D"gmail_quote" style=3D"margin: 0px 0px 0px 0.8ex; border-lef=
t-width: 1px; border-left-color: rgb(204, 204, 204); border-left-style: sol=
id; padding-left: 1ex;"><div>A third issue I haven't seen discussed is the =
case of a mix of declarations and preexisting variables on the left of =3D.=
</div></blockquote><div><br></div><div>I don't think this is a problem. Sin=
ce the destructuring is just sugar, I think it doesn't need to handle more =
complex cases such as this one; for those, there's always manual unpacking =
with get<n>() or std::tie.</div></div></div></div>
<p></p>
-- <br />
<br />
--- <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 />
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/">http://groups.google.com/a/isocpp.org/group/std-proposals/<=
/a>.<br />
------=_Part_199_621786889.1406540277743--
.
Author: David Krauss <potswa@gmail.com>
Date: Mon, 28 Jul 2014 19:01:29 +0800
Raw View
--Apple-Mail=_BA863A1D-5982-4C53-9080-C755E5D841D8
Content-Transfer-Encoding: quoted-printable
Content-Type: text/plain; charset=ISO-8859-1
On 2014-06-15, at 8:07 PM, walter1234 <walter2bz@gmail.com> wrote:
> Something related, would it be possible to retrofit swifts .0 , .1 .. syn=
tax for tuple member access into C++?
Or, a way to convert a constant expression argument to a std::integral_cons=
tant type. That would allow a subscript operator template to be defined, su=
ch that tuple[ 0 ] could have a different type from tuple[ 1 ]. It would al=
so provide a generally convenient gateway between constexpr and template me=
taprogramming.
--=20
---=20
You received this message because you are subscribed to the Google Groups "=
ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposa=
ls/.
--Apple-Mail=_BA863A1D-5982-4C53-9080-C755E5D841D8
Content-Transfer-Encoding: quoted-printable
Content-Type: text/html; charset=ISO-8859-1
<html><head><meta http-equiv=3D"Content-Type" content=3D"text/html charset=
=3Dwindows-1252"></head><body style=3D"word-wrap: break-word; -webkit-nbsp-=
mode: space; -webkit-line-break: after-white-space;"><br><div><div>On 2014&=
ndash;06–15, at 8:07 PM, walter1234 <<a href=3D"mailto:walter2bz@g=
mail.com">walter2bz@gmail.com</a>> wrote:</div><br class=3D"Apple-interc=
hange-newline"><blockquote type=3D"cite"><div dir=3D"ltr"><div>Something re=
lated, would it be possible to retrofit swifts .0 , .1 .. syntax for tuple =
member access into C++?</div></div></blockquote><div><br></div><div>Or, a w=
ay to convert a constant expression argument to a <font face=3D"Courier">st=
d::integral_constant</font> type. That would allow a subscript operator tem=
plate to be defined, such that <font face=3D"Courier">tuple[ 0 ]</font> cou=
ld have a different type from <font face=3D"Courier">tuple[ 1 ]</font>. It =
would also provide a generally convenient gateway between constexpr and tem=
plate metaprogramming.</div></div><br></body></html>
<p></p>
-- <br />
<br />
--- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals" group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<br />
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/">http://groups.google.com/a/isocpp.org/group/std-proposals/<=
/a>.<br />
--Apple-Mail=_BA863A1D-5982-4C53-9080-C755E5D841D8--
.
Author: inkwizytoryankes@gmail.com
Date: Mon, 28 Jul 2014 11:00:52 -0700 (PDT)
Raw View
------=_Part_491_862300060.1406570453037
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
user literals could be help there:
template<int i>
class S{
};
template<char... K>
constexpr S<string_to_int<K...>::value> operator"" _f()
{
return {};
}
struct Tuple : public std::tuple<char, int, std::string>
{
template<int i>
auto operator[](S<i>) -> decltype(auto)
{
return (std::get<i>(*this));
}
};
int main()
{
Tuple a;
a[0_f] =3D 5;
std::cout << a[0_f] << std::endl;
}
On Monday, July 28, 2014 1:01:46 PM UTC+2, David Krauss wrote:
>
>
> On 2014=E2=80=9306=E2=80=9315, at 8:07 PM, walter1234 <walt...@gmail.com =
<javascript:>>=20
> wrote:
>
> Something related, would it be possible to retrofit swifts .0 , .1 ..=20
> syntax for tuple member access into C++?
>
>
> Or, a way to convert a constant expression argument to a=20
> std::integral_constant type. That would allow a subscript operator=20
> template to be defined, such that tuple[ 0 ] could have a different type=
=20
> from tuple[ 1 ]. It would also provide a generally convenient gateway=20
> between constexpr and template metaprogramming.
>
>
--=20
---=20
You received this message because you are subscribed to the Google Groups "=
ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposa=
ls/.
------=_Part_491_862300060.1406570453037
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
user literals could be help there:<br><div class=3D"prettyprint" style=3D"b=
ackground-color: rgb(250, 250, 250); border-color: rgb(187, 187, 187); bord=
er-style: solid; border-width: 1px; word-wrap: break-word;"><code class=3D"=
prettyprint"><div class=3D"subprettyprint"><span style=3D"color: #000;" cla=
ss=3D"styled-by-prettify"><br></span><span style=3D"color: #008;" class=3D"=
styled-by-prettify">template</span><span style=3D"color: #660;" class=3D"st=
yled-by-prettify"><</span><span style=3D"color: #008;" class=3D"styled-b=
y-prettify">int</span><span style=3D"color: #000;" class=3D"styled-by-prett=
ify"> i</span><span style=3D"color: #660;" class=3D"styled-by-prettify">>=
;</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br></spa=
n><span style=3D"color: #008;" class=3D"styled-by-prettify">class</span><sp=
an style=3D"color: #000;" class=3D"styled-by-prettify"> S</span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">{</span><span style=3D"color=
: #000;" class=3D"styled-by-prettify"><br></span><span style=3D"color: #660=
;" class=3D"styled-by-prettify">};</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"><br><br></span><span style=3D"color: #008;" class=
=3D"styled-by-prettify">template</span><span style=3D"color: #660;" class=
=3D"styled-by-prettify"><</span><span style=3D"color: #008;" class=3D"st=
yled-by-prettify">char</span><span style=3D"color: #660;" class=3D"styled-b=
y-prettify">...</span><span style=3D"color: #000;" class=3D"styled-by-prett=
ify"> K</span><span style=3D"color: #660;" class=3D"styled-by-prettify">>=
;</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br> =
; </span><span style=3D"color: #008;" class=3D"styled-by-prettify">constexp=
r</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> S</span>=
<span style=3D"color: #660;" class=3D"styled-by-prettify"><</span><span =
style=3D"color: #000;" class=3D"styled-by-prettify">string_to_int</span><sp=
an style=3D"color: #660;" class=3D"styled-by-prettify"><</span><span sty=
le=3D"color: #000;" class=3D"styled-by-prettify">K</span><span style=3D"col=
or: #660;" class=3D"styled-by-prettify">...>::</span><span style=3D"colo=
r: #000;" class=3D"styled-by-prettify">value</span><span style=3D"color: #6=
60;" class=3D"styled-by-prettify">></span><span style=3D"color: #000;" c=
lass=3D"styled-by-prettify"> </span><span style=3D"color: #008;" class=3D"s=
tyled-by-prettify">operator</span><span style=3D"color: #080;" class=3D"sty=
led-by-prettify">""</span><span style=3D"color: #000;" class=3D"styled-by-p=
rettify"> _f</span><span style=3D"color: #660;" class=3D"styled-by-prettify=
">()</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br></=
span><span style=3D"color: #660;" class=3D"styled-by-prettify">{</span><spa=
n style=3D"color: #000;" class=3D"styled-by-prettify"><br> </span><sp=
an style=3D"color: #008;" class=3D"styled-by-prettify">return</span><span s=
tyle=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"c=
olor: #660;" class=3D"styled-by-prettify">{};</span><span style=3D"color: #=
000;" class=3D"styled-by-prettify"><br></span><span style=3D"color: #660;" =
class=3D"styled-by-prettify">}</span><span style=3D"color: #000;" class=3D"=
styled-by-prettify"><br><br></span><span style=3D"color: #008;" class=3D"st=
yled-by-prettify">struct</span><span style=3D"color: #000;" class=3D"styled=
-by-prettify"> </span><span style=3D"color: #606;" class=3D"styled-by-prett=
ify">Tuple</span><span style=3D"color: #000;" class=3D"styled-by-prettify">=
</span><span style=3D"color: #660;" class=3D"styled-by-prettify">:</span><=
span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span styl=
e=3D"color: #008;" class=3D"styled-by-prettify">public</span><span style=3D=
"color: #000;" class=3D"styled-by-prettify"> std</span><span style=3D"color=
: #660;" class=3D"styled-by-prettify">::</span><span style=3D"color: #000;"=
class=3D"styled-by-prettify">tuple</span><span style=3D"color: #660;" clas=
s=3D"styled-by-prettify"><</span><span style=3D"color: #008;" class=3D"s=
tyled-by-prettify">char</span><span style=3D"color: #660;" class=3D"styled-=
by-prettify">,</span><span style=3D"color: #000;" class=3D"styled-by-pretti=
fy"> </span><span style=3D"color: #008;" class=3D"styled-by-prettify">int</=
span><span style=3D"color: #660;" class=3D"styled-by-prettify">,</span><spa=
n style=3D"color: #000;" class=3D"styled-by-prettify"> std</span><span styl=
e=3D"color: #660;" class=3D"styled-by-prettify">::</span><span style=3D"col=
or: #008;" class=3D"styled-by-prettify">string</span><span style=3D"color: =
#660;" class=3D"styled-by-prettify">></span><span style=3D"color: #000;"=
class=3D"styled-by-prettify"><br></span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">{</span><span style=3D"color: #000;" class=3D"style=
d-by-prettify"><br> </span><span style=3D"color: #008;" class=3D"styl=
ed-by-prettify">template</span><span style=3D"color: #660;" class=3D"styled=
-by-prettify"><</span><span style=3D"color: #008;" class=3D"styled-by-pr=
ettify">int</span><span style=3D"color: #000;" class=3D"styled-by-prettify"=
> i</span><span style=3D"color: #660;" class=3D"styled-by-prettify">></s=
pan><span style=3D"color: #000;" class=3D"styled-by-prettify"><br> </=
span><span style=3D"color: #008;" class=3D"styled-by-prettify">auto</span><=
span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span styl=
e=3D"color: #008;" class=3D"styled-by-prettify">operator</span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">[](</span><span style=3D"col=
or: #000;" class=3D"styled-by-prettify">S</span><span style=3D"color: #080;=
" class=3D"styled-by-prettify"><i></span><span style=3D"color: #660;"=
class=3D"styled-by-prettify">)</span><span style=3D"color: #000;" class=3D=
"styled-by-prettify"> </span><span style=3D"color: #660;" class=3D"styled-b=
y-prettify">-></span><span style=3D"color: #000;" class=3D"styled-by-pre=
ttify"> </span><span style=3D"color: #008;" class=3D"styled-by-prettify">de=
cltype</span><span style=3D"color: #660;" class=3D"styled-by-prettify">(</s=
pan><span style=3D"color: #008;" class=3D"styled-by-prettify">auto</span><s=
pan style=3D"color: #660;" class=3D"styled-by-prettify">)</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"><br> </span><span styl=
e=3D"color: #660;" class=3D"styled-by-prettify">{</span><span style=3D"colo=
r: #000;" class=3D"styled-by-prettify"><br> </span><span style=
=3D"color: #008;" class=3D"styled-by-prettify">return</span><span style=3D"=
color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #6=
60;" class=3D"styled-by-prettify">(</span><span style=3D"color: #000;" clas=
s=3D"styled-by-prettify">std</span><span style=3D"color: #660;" class=3D"st=
yled-by-prettify">::</span><span style=3D"color: #008;" class=3D"styled-by-=
prettify">get</span><span style=3D"color: #080;" class=3D"styled-by-prettif=
y"><i></span><span style=3D"color: #660;" class=3D"styled-by-prettify=
">(*</span><span style=3D"color: #008;" class=3D"styled-by-prettify">this</=
span><span style=3D"color: #660;" class=3D"styled-by-prettify">));</span><s=
pan style=3D"color: #000;" class=3D"styled-by-prettify"><br> </span><=
span style=3D"color: #660;" class=3D"styled-by-prettify">}</span><span styl=
e=3D"color: #000;" class=3D"styled-by-prettify"><br></span><span style=3D"c=
olor: #660;" class=3D"styled-by-prettify">};</span><span style=3D"color: #0=
00;" class=3D"styled-by-prettify"><br><br></span><span style=3D"color: #008=
;" class=3D"styled-by-prettify">int</span><span style=3D"color: #000;" clas=
s=3D"styled-by-prettify"> main</span><span style=3D"color: #660;" class=3D"=
styled-by-prettify">()</span><span style=3D"color: #000;" class=3D"styled-b=
y-prettify"><br></span><span style=3D"color: #660;" class=3D"styled-by-pret=
tify">{</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br=
> </span><span style=3D"color: #606;" class=3D"styled-by-prettify">Tu=
ple</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> a</spa=
n><span style=3D"color: #660;" class=3D"styled-by-prettify">;</span><span s=
tyle=3D"color: #000;" class=3D"styled-by-prettify"><br> a</span><span=
style=3D"color: #660;" class=3D"styled-by-prettify">[</span><span style=3D=
"color: #066;" class=3D"styled-by-prettify">0</span><span style=3D"color: #=
000;" class=3D"styled-by-prettify">_f</span><span style=3D"color: #660;" cl=
ass=3D"styled-by-prettify">]</span><span style=3D"color: #000;" class=3D"st=
yled-by-prettify"> </span><span style=3D"color: #660;" class=3D"styled-by-p=
rettify">=3D</span><span style=3D"color: #000;" class=3D"styled-by-prettify=
"> </span><span style=3D"color: #066;" class=3D"styled-by-prettify">5</span=
><span style=3D"color: #660;" class=3D"styled-by-prettify">;</span><span st=
yle=3D"color: #000;" class=3D"styled-by-prettify"><br> std</span><spa=
n style=3D"color: #660;" class=3D"styled-by-prettify">::</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify">cout </span><span style=3D"c=
olor: #660;" class=3D"styled-by-prettify"><<</span><span style=3D"col=
or: #000;" class=3D"styled-by-prettify"> a</span><span style=3D"color: #660=
;" class=3D"styled-by-prettify">[</span><span style=3D"color: #066;" class=
=3D"styled-by-prettify">0</span><span style=3D"color: #000;" class=3D"style=
d-by-prettify">_f</span><span style=3D"color: #660;" class=3D"styled-by-pre=
ttify">]</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> <=
/span><span style=3D"color: #660;" class=3D"styled-by-prettify"><<</s=
pan><span style=3D"color: #000;" class=3D"styled-by-prettify"> std</span><s=
pan style=3D"color: #660;" class=3D"styled-by-prettify">::</span><span styl=
e=3D"color: #000;" class=3D"styled-by-prettify">endl</span><span style=3D"c=
olor: #660;" class=3D"styled-by-prettify">;</span><span style=3D"color: #00=
0;" class=3D"styled-by-prettify"><br></span><span style=3D"color: #660;" cl=
ass=3D"styled-by-prettify">}</span></div></code></div><br><br>On Monday, Ju=
ly 28, 2014 1:01:46 PM UTC+2, David Krauss wrote:<blockquote class=3D"gmail=
_quote" style=3D"margin: 0;margin-left: 0.8ex;border-left: 1px #ccc solid;p=
adding-left: 1ex;"><div style=3D"word-wrap:break-word"><br><div><div>On 201=
4=E2=80=9306=E2=80=9315, at 8:07 PM, walter1234 <<a href=3D"javascript:"=
target=3D"_blank" gdf-obfuscated-mailto=3D"6Wv4Hf-vSbAJ" onmousedown=3D"th=
is.href=3D'javascript:';return true;" onclick=3D"this.href=3D'javascript:';=
return true;">walt...@gmail.com</a>> wrote:</div><br><blockquote type=3D=
"cite"><div dir=3D"ltr"><div>Something related, would it be possible to ret=
rofit swifts .0 , .1 .. syntax for tuple member access into C++?</div></div=
></blockquote><div><br></div><div>Or, a way to convert a constant expressio=
n argument to a <font face=3D"Courier">std::integral_constant</font> type. =
That would allow a subscript operator template to be defined, such that <fo=
nt face=3D"Courier">tuple[ 0 ]</font> could have a different type from <fon=
t face=3D"Courier">tuple[ 1 ]</font>. It would also provide a generally con=
venient gateway between constexpr and template metaprogramming.</div></div>=
<br></div></blockquote>
<p></p>
-- <br />
<br />
--- <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 />
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/">http://groups.google.com/a/isocpp.org/group/std-proposals/<=
/a>.<br />
------=_Part_491_862300060.1406570453037--
.
Author: Bengt Gustafsson <bengt.gustafsson@beamways.com>
Date: Tue, 29 Jul 2014 01:58:02 -0700 (PDT)
Raw View
------=_Part_3404_1368456676.1406624282311
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
I wasn't thinking of my idea
inline { x, int y } =3D func();
as something specific to the case that func() returns a tuple, that would=
=20
be a terrible wart connecting a core language feature to a std class.=20
Instead I thought of it as a general reversal of the {} initializer i.e. to=
=20
pick up the members of whatever object/tuple/struct that func returns().
Thus tie() or get<> does not solve the general case that this feature does.
Den m=C3=A5ndagen den 28:e juli 2014 kl. 11:37:57 UTC+2 skrev=20
leszek....@gmail.com:
>
> Something related, would it be possible to retrofit swifts .0 , .1 ..=20
>> syntax for tuple member access into C++?
>>
>
> I really like that idea, especially since get<0>(x) is so verbose...
> =20
>
>> I think I'd rather have that than destructuring sugar.
>>
>
> ... but I'd rather have it "in addition to" destructuring sugar.
>
>
> inline { int x, int y} =3D p;
>>
>
> This is elegant in both reuse of keywords, and this idea of reverse=20
> initializers, but my issue with it is the increased verbosity; after all,=
=20
> the whole point of this proposal is to have a short and handy sugar synta=
x=20
> for getting at the unknown-type (or rather "I-don't-care"-type) elements =
of=20
> a tuple.
>
> A third issue I haven't seen discussed is the case of a mix of=20
>> declarations and preexisting variables on the left of =3D.
>>
>
> I don't think this is a problem. Since the destructuring is just sugar, I=
=20
> think it doesn't need to handle more complex cases such as this one; for=
=20
> those, there's always manual unpacking with get<n>() or std::tie.
>
--=20
---=20
You received this message because you are subscribed to the Google Groups "=
ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposa=
ls/.
------=_Part_3404_1368456676.1406624282311
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr">I wasn't thinking of my idea<div><br></div><div><div class=
=3D"prettyprint" style=3D"border: 1px solid rgb(187, 187, 187); word-wrap: =
break-word; background-color: rgb(250, 250, 250);"><code class=3D"prettypri=
nt"><div class=3D"subprettyprint"><span style=3D"color: #008;" class=3D"sty=
led-by-prettify">inline</span><span style=3D"color: #000;" class=3D"styled-=
by-prettify"> </span><span style=3D"color: #660;" class=3D"styled-by-pretti=
fy">{</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> x</s=
pan><span style=3D"color: #660;" class=3D"styled-by-prettify">,</span><span=
style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D=
"color: #008;" class=3D"styled-by-prettify">int</span><span style=3D"color:=
#000;" class=3D"styled-by-prettify"> y </span><span style=3D"color: #660;"=
class=3D"styled-by-prettify">}</span><span style=3D"color: #000;" class=3D=
"styled-by-prettify"> </span><span style=3D"color: #660;" class=3D"styled-b=
y-prettify">=3D</span><span style=3D"color: #000;" class=3D"styled-by-prett=
ify"> func</span><span style=3D"color: #660;" class=3D"styled-by-prettify">=
();</span></div></code></div><br></div><div><br></div><div>as something spe=
cific to the case that func() returns a tuple, that would be a terrible war=
t connecting a core language feature to a std class. Instead I thought of i=
t as a general reversal of the {} initializer i.e. to pick up the members o=
f whatever object/tuple/struct that func returns().</div><div><br></div><di=
v>Thus tie() or get<> does not solve the general case that this featu=
re does.</div><div><br><br>Den m=C3=A5ndagen den 28:e juli 2014 kl. 11:37:5=
7 UTC+2 skrev leszek....@gmail.com:<blockquote class=3D"gmail_quote" style=
=3D"margin: 0;margin-left: 0.8ex;border-left: 1px #ccc solid;padding-left: =
1ex;"><div dir=3D"ltr"><blockquote class=3D"gmail_quote" style=3D"margin:0;=
margin-left:0.8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir=3D"=
ltr"><div>Something related, would it be possible to retrofit swifts .0 , .=
1 .. syntax for tuple member access into C++?</div></div></blockquote><div>=
<br></div><div>I really like that idea, especially since get<0>(x) is=
so verbose...</div><div> </div><blockquote class=3D"gmail_quote" styl=
e=3D"margin:0;margin-left:0.8ex;border-left:1px #ccc solid;padding-left:1ex=
"><div dir=3D"ltr"><div>I think I'd rather have that than destructuring sug=
ar.<br></div></div></blockquote><div><br></div><div>... but I'd rather have=
it "in addition to" destructuring sugar.</div><div><br></div><div><br></di=
v><div><div dir=3D"ltr"><blockquote class=3D"gmail_quote" style=3D"margin:0=
px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);b=
order-left-style:solid;padding-left:1ex">inline { int x, int y} =3D p;<br><=
/blockquote><div><br></div><div>This is elegant in both reuse of keywords, =
and this idea of reverse initializers, but my issue with it is the increase=
d verbosity; after all, the whole point of this proposal is to have a short=
and handy sugar syntax for getting at the unknown-type (or rather "I-don't=
-care"-type) elements of a tuple.</div><div><br></div><blockquote class=3D"=
gmail_quote" style=3D"margin:0px 0px 0px 0.8ex;border-left-width:1px;border=
-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div=
>A third issue I haven't seen discussed is the case of a mix of declaration=
s and preexisting variables on the left of =3D.</div></blockquote><div><br>=
</div><div>I don't think this is a problem. Since the destructuring is just=
sugar, I think it doesn't need to handle more complex cases such as this o=
ne; for those, there's always manual unpacking with get<n>() or std::=
tie.</div></div></div></div></blockquote></div></div>
<p></p>
-- <br />
<br />
--- <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 />
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/">http://groups.google.com/a/isocpp.org/group/std-proposals/<=
/a>.<br />
------=_Part_3404_1368456676.1406624282311--
.
Author: walter1234 <walter2bz@gmail.com>
Date: Wed, 30 Jul 2014 07:29:33 -0700 (PDT)
Raw View
------=_Part_4037_2062702727.1406730573932
Content-Type: text/plain; charset=UTF-8
Would `struct` in an lvalue location work , directly analogous to the
destructuring in rust, just with sequential access allowed to named structs
(so they can be used like tuples in functional languages)
eg
struct { auto x,auto y,auto z } = std::make_tuple(1,2.0,"three");
//x=1, y=2.0, z="three"
Such a shame how simple brackets and commas already parse in C++.. the
elegance of let (x,y)=... in rust is a big draw.
--
---
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_4037_2062702727.1406730573932
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr"><font color=3D"#000000" face=3D"arial, sans-serif">Would `=
struct` in an lvalue location work , directly analogous to the destructurin=
g in rust, just with sequential access allowed to named structs (so th=
ey can be used like tuples in functional languages)</font><div><font c=
olor=3D"#000000" face=3D"arial, sans-serif"><br></font></div><div><font col=
or=3D"#000000" face=3D"arial, sans-serif">eg </font></div><div><font c=
olor=3D"#000000" face=3D"arial, sans-serif"><br></font></div><div><font col=
or=3D"#000000" face=3D"arial, sans-serif"> struct { auto =
x,auto y,auto z } =3D std::make_tuple(1,2.0,"three"); //x=3D1, y=3D2.=
0, z=3D"three"</font></div><div><font color=3D"#000000" face=3D"arial, sans=
-serif"><br></font></div><div><font color=3D"#000000" face=3D"arial, sans-s=
erif"><br></font></div><div><font color=3D"#000000" face=3D"arial, sans-ser=
if">Such a shame how simple brackets and commas already parse in C++..=
the elegance of let (x,y)=3D... in rust is a big draw.</font></div><div><f=
ont color=3D"#000000" face=3D"arial, sans-serif"><br></font></div><div><fon=
t color=3D"#000000" face=3D"arial, sans-serif"><br></font></div></div>
<p></p>
-- <br />
<br />
--- <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 />
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/">http://groups.google.com/a/isocpp.org/group/std-proposals/<=
/a>.<br />
------=_Part_4037_2062702727.1406730573932--
.
Author: Tony V E <tvaneerd@gmail.com>
Date: Wed, 30 Jul 2014 12:30:18 -0400
Raw View
--089e0149338cfaaedd04ff6bab84
Content-Type: text/plain; charset=UTF-8
On Wed, Jul 30, 2014 at 10:29 AM, walter1234 <walter2bz@gmail.com> wrote:
> Would `struct` in an lvalue location work , directly analogous to the
> destructuring in rust, just with sequential access allowed to named structs
> (so they can be used like tuples in functional languages)
>
> eg
>
> struct { auto x,auto y,auto z } = std::make_tuple(1,2.0,"three");
> //x=1, y=2.0, z="three"
>
>
> Such a shame how simple brackets and commas already parse in C++.. the
> elegance of let (x,y)=... in rust is a big draw.
>
>
>
We could just go all out and invent new brackets: :{ x, y, z }: or {: :}
or {| |} or ...
(I suspect {| is currently always an error, whereas {: could be the start
of something like {::x, and (not sure) maybe :{ could be part of a
conditional-operator b ? x :{y,z}, although I don't think that is valid...
yet.)
Tony
--
---
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/.
--089e0149338cfaaedd04ff6bab84
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr"><br><div class=3D"gmail_extra"><br><br><div class=3D"gmail=
_quote">On Wed, Jul 30, 2014 at 10:29 AM, walter1234 <span dir=3D"ltr"><=
<a href=3D"mailto:walter2bz@gmail.com" target=3D"_blank">walter2bz@gmail.co=
m</a>></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 dir=3D"ltr"><font color=3D"#000000" fac=
e=3D"arial, sans-serif">Would `struct` in an lvalue location work , directl=
y analogous to the destructuring in rust, just with sequential=C2=A0access =
allowed to named structs (so they can be used like tuples in functional=C2=
=A0languages)</font><div>
<font color=3D"#000000" face=3D"arial, sans-serif"><br></font></div><div><f=
ont color=3D"#000000" face=3D"arial, sans-serif">eg=C2=A0</font></div><div>=
<font color=3D"#000000" face=3D"arial, sans-serif"><br></font></div><div><f=
ont color=3D"#000000" face=3D"arial, sans-serif">=C2=A0 =C2=A0struct =C2=A0=
{ auto x,auto y,auto z } =3D std::make_tuple(1,2.0,"three"); =C2=
=A0//x=3D1, y=3D2.0, z=3D"three"</font></div>
<div><font color=3D"#000000" face=3D"arial, sans-serif"><br></font></div><d=
iv><font color=3D"#000000" face=3D"arial, sans-serif"><br></font></div><div=
><font color=3D"#000000" face=3D"arial, sans-serif">Such a shame how simple=
=C2=A0brackets and commas already parse in C++.. the elegance of let (x,y)=
=3D... in rust is a big draw.</font></div>
<div><font color=3D"#000000" face=3D"arial, sans-serif"><br></font></div><b=
r></div></blockquote></div><br></div><div class=3D"gmail_extra">We could ju=
st go all out and invent new brackets:=C2=A0 :{ x, y, z }: or {: :} or {| |=
} or ...<br>
</div><div class=3D"gmail_extra">(I suspect {| is currently always an error=
, whereas {: could be the start of something like {::x, and (not sure) mayb=
e :{ could be part of a conditional-operator b ? x :{y,z}, although I don&#=
39;t think that is valid... yet.)<br>
</div><div class=3D"gmail_extra"><br></div><div class=3D"gmail_extra">Tony<=
br></div></div>
<p></p>
-- <br />
<br />
--- <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 />
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 />
--089e0149338cfaaedd04ff6bab84--
.
Author: Ville Voutilainen <ville.voutilainen@gmail.com>
Date: Wed, 30 Jul 2014 20:11:50 +0300
Raw View
On 30 July 2014 19:30, Tony V E <tvaneerd@gmail.com> wrote:
>
>
>
> On Wed, Jul 30, 2014 at 10:29 AM, walter1234 <walter2bz@gmail.com> wrote:
>>
>> Would `struct` in an lvalue location work , directly analogous to the
>> destructuring in rust, just with sequential access allowed to named structs
>> (so they can be used like tuples in functional languages)
>>
>> eg
>>
>> struct { auto x,auto y,auto z } = std::make_tuple(1,2.0,"three");
>> //x=1, y=2.0, z="three"
>>
>>
>> Such a shame how simple brackets and commas already parse in C++.. the
>> elegance of let (x,y)=... in rust is a big draw.
>>
>>
>
> We could just go all out and invent new brackets: :{ x, y, z }: or {: :} or
> {| |} or ...
> (I suspect {| is currently always an error, whereas {: could be the start of
> something like {::x, and (not sure) maybe :{ could be part of a
> conditional-operator b ? x :{y,z}, although I don't think that is valid...
> yet.)
I have serious trouble seeing sufficient motivation to invent new syntax to
support more convenient ways to unpack ad-hoc types like tuples. Just
because Rust does such things (as does Python) is not a sufficient
reason.
--
---
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/.
.
Author: Tony V E <tvaneerd@gmail.com>
Date: Wed, 30 Jul 2014 13:39:08 -0400
Raw View
--001a1134716a1e5eb104ff6ca26a
Content-Type: text/plain; charset=UTF-8
On Wed, Jul 30, 2014 at 1:11 PM, Ville Voutilainen <
ville.voutilainen@gmail.com> wrote:
> On 30 July 2014 19:30, Tony V E <tvaneerd@gmail.com> wrote:
> >
>
> > We could just go all out and invent new brackets: :{ x, y, z }: or {:
> :} or
> > {| |} or ...
> > (I suspect {| is currently always an error, whereas {: could be the
> start of
> > something like {::x, and (not sure) maybe :{ could be part of a
> > conditional-operator b ? x :{y,z}, although I don't think that is
> valid...
> > yet.)
>
>
> I have serious trouble seeing sufficient motivation to invent new syntax to
> support more convenient ways to unpack ad-hoc types like tuples. Just
> because Rust does such things (as does Python) is not a sufficient
> reason.
>
>
I'd like better support for tuples, but I agree new brackets is going to
far, even though I suggested it. Unless the new brackets had useful meaning
beyond tuples.
(I often suggest things that I might not agree with, or at least haven't
decided on yet, in case others like it or it leads to something even
better.)
Tony
--
---
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/.
--001a1134716a1e5eb104ff6ca26a
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr"><br><div class=3D"gmail_extra"><br><br><div class=3D"gmail=
_quote">On Wed, Jul 30, 2014 at 1:11 PM, Ville Voutilainen <span dir=3D"ltr=
"><<a href=3D"mailto:ville.voutilainen@gmail.com" target=3D"_blank">vill=
e.voutilainen@gmail.com</a>></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 class=3D"HOEnZb"><div class=3D"h5">On 3=
0 July 2014 19:30, Tony V E <<a href=3D"mailto:tvaneerd@gmail.com">tvane=
erd@gmail.com</a>> wrote:<br>
><br>
<br>
> We could just go all out and invent new brackets: =C2=A0:{ x, y, z }: =
or {: :} or<br>
> {| |} or ...<br>
> (I suspect {| is currently always an error, whereas {: could be the st=
art of<br>
> something like {::x, and (not sure) maybe :{ could be part of a<br>
> conditional-operator b ? x :{y,z}, although I don't think that is =
valid...<br>
> yet.)<br>
<br>
<br>
</div></div>I have serious trouble seeing sufficient motivation to invent n=
ew syntax to<br>
support more convenient ways to unpack ad-hoc types like tuples. Just<br>
because Rust does such things (as does Python) is not a sufficient<br>
reason.<br>
<div class=3D"HOEnZb"><div class=3D"h5"><br></div></div></blockquote><div><=
br></div><div>I'd like better support for tuples, but I agree new brack=
ets is going to far, even though I suggested it. Unless the new brackets ha=
d useful meaning beyond tuples.<br>
(I often suggest things that I might not agree with, or at least haven'=
t decided on yet, in case others like it or it leads to something even bett=
er.)<br><br></div>Tony<br></div><br></div></div>
<p></p>
-- <br />
<br />
--- <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 />
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 />
--001a1134716a1e5eb104ff6ca26a--
.
Author: Edward Catmur <ed@catmur.co.uk>
Date: Wed, 30 Jul 2014 16:10:25 -0700 (PDT)
Raw View
------=_Part_711_1377563527.1406761826023
Content-Type: text/plain; charset=UTF-8
On Wednesday, 30 July 2014 18:39:11 UTC+1, Tony V E wrote:
>
> On Wed, Jul 30, 2014 at 1:11 PM, Ville Voutilainen <ville.vo...@gmail.com
> <javascript:>> wrote:
>
>> On 30 July 2014 19:30, Tony V E <tvan...@gmail.com <javascript:>> wrote:
>>
> I have serious trouble seeing sufficient motivation to invent new syntax to
>> support more convenient ways to unpack ad-hoc types like tuples. Just
>> because Rust does such things (as does Python) is not a sufficient
>> reason.
>
>
> I'd like better support for tuples, but I agree new brackets is going to
> far, even though I suggested it. Unless the new brackets had useful meaning
> beyond tuples.
> (I often suggest things that I might not agree with, or at least haven't
> decided on yet, in case others like it or it leads to something even
> better.)
>
I'm sure other people have already mentioned it, but I'd like to reiterate
that it is already entirely possible to unpack tuples and similar using
apply (n3915), at the cost of an extra level of nesting:
auto t = std::make_tuple("hello", 123.45, 66);
apply([&](auto s, auto d, auto i){
std::cout << s << d << i;
}, t);
Iterating over an associative container:
std::map<int, std::string> m;
for (auto&& kv: m) {
apply([&](auto const&& k, auto&& v) {
// ...
}, kv);
}
Any new syntax would have to represent a significant improvement over this,
which seems a pretty tough bar to attain.
It would probably read better with the arguments in the opposite order, but
it's trivial to write the equivalent of unpack = flip apply. One can even
write an "unpacking operator" using everyone's favorite overloadable binary
operator:
template<typename T, typename F> decltype(auto) operator->*(T&& t, F&& f) {
return std::apply(std::forward<F>(f), std::forward<T>(t));
}
auto t = std::make_tuple("hello", 123.45, 66);
t ->* [&](auto s, auto d, auto i) { // t goes to s, d, and i
std::cout << s << d << i;
};
(Heh.)
--
---
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_711_1377563527.1406761826023
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr">On Wednesday, 30 July 2014 18:39:11 UTC+1, Tony V E wrote=
:<blockquote class=3D"gmail_quote" style=3D"margin: 0;margin-left: 0.8ex;bo=
rder-left: 1px #ccc solid;padding-left: 1ex;"><div dir=3D"ltr">On Wed, Jul =
30, 2014 at 1:11 PM, Ville Voutilainen <span dir=3D"ltr"><<a href=3D"jav=
ascript:" target=3D"_blank" gdf-obfuscated-mailto=3D"jM27z-j8l3cJ" onmoused=
own=3D"this.href=3D'javascript:';return true;" onclick=3D"this.href=3D'java=
script:';return true;">ville.vo...@gmail.com</a>></span> wrote:<br><div>=
<div class=3D"gmail_quote">
<blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1p=
x #ccc solid;padding-left:1ex"><div><div>On 30 July 2014 19:30, Tony V E &l=
t;<a href=3D"javascript:" target=3D"_blank" gdf-obfuscated-mailto=3D"jM27z-=
j8l3cJ" onmousedown=3D"this.href=3D'javascript:';return true;" onclick=3D"t=
his.href=3D'javascript:';return true;">tvan...@gmail.com</a>> wrote:&nbs=
p;</div></div></blockquote></div></div></div></blockquote><blockquote class=
=3D"gmail_quote" style=3D"margin: 0;margin-left: 0.8ex;border-left: 1px #cc=
c solid;padding-left: 1ex;"><div dir=3D"ltr"><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:1ex"><div><div>I have serious trouble seeing su=
fficient motivation to invent new syntax to<br></div></div>
support more convenient ways to unpack ad-hoc types like tuples. Just<br>
because Rust does such things (as does Python) is not a sufficient<br>
reason.</blockquote><div><br></div><div>I'd like better support for tuples,=
but I agree new brackets is going to far, even though I suggested it. Unle=
ss the new brackets had useful meaning beyond tuples.<br>
(I often suggest things that I might not agree with, or at least haven't de=
cided on yet, in case others like it or it leads to something even better.)=
<br></div></div></div></div></blockquote><div><br></div><div>I'm sure other=
people have already mentioned it, but I'd like to reiterate that it is alr=
eady entirely possible to unpack tuples and similar using apply (n3915), at=
the cost of an extra level of nesting:</div><div><br></div><div class=3D"p=
rettyprint" style=3D"background-color: rgb(250, 250, 250); border: 1px soli=
d rgb(187, 187, 187); word-wrap: break-word;"><code class=3D"prettyprint"><=
div class=3D"subprettyprint"><span style=3D"color: #008;" class=3D"styled-b=
y-prettify">auto</span><span style=3D"color: #000;" class=3D"styled-by-pret=
tify"> t </span><span style=3D"color: #660;" class=3D"styled-by-prettify">=
=3D</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> std</s=
pan><span style=3D"color: #660;" class=3D"styled-by-prettify">::</span><spa=
n style=3D"color: #000;" class=3D"styled-by-prettify">make_tuple</span><spa=
n style=3D"color: #660;" class=3D"styled-by-prettify">(</span><span style=
=3D"color: #080;" class=3D"styled-by-prettify">"hello"</span><span style=3D=
"color: #660;" class=3D"styled-by-prettify">,</span><span style=3D"color: #=
000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #066;" cla=
ss=3D"styled-by-prettify">123.45</span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">,</span><span style=3D"color: #000;" class=3D"style=
d-by-prettify"> </span><span style=3D"color: #066;" class=3D"styled-by-pret=
tify">66</span><span style=3D"color: #660;" class=3D"styled-by-prettify">);=
</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br>apply<=
/span><span style=3D"color: #660;" class=3D"styled-by-prettify">([&](</=
span><span style=3D"color: #008;" class=3D"styled-by-prettify">auto</span><=
span style=3D"color: #000;" class=3D"styled-by-prettify"> s</span><span sty=
le=3D"color: #660;" class=3D"styled-by-prettify">,</span><span style=3D"col=
or: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #008;=
" class=3D"styled-by-prettify">auto</span><span style=3D"color: #000;" clas=
s=3D"styled-by-prettify"> d</span><span style=3D"color: #660;" class=3D"sty=
led-by-prettify">,</span><span style=3D"color: #000;" class=3D"styled-by-pr=
ettify"> </span><span style=3D"color: #008;" class=3D"styled-by-prettify">a=
uto</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> i</spa=
n><span style=3D"color: #660;" class=3D"styled-by-prettify">){</span><span =
style=3D"color: #000;" class=3D"styled-by-prettify"><br> std</span><s=
pan style=3D"color: #660;" class=3D"styled-by-prettify">::</span><span styl=
e=3D"color: #000;" class=3D"styled-by-prettify">cout </span><span style=3D"=
color: #660;" class=3D"styled-by-prettify"><<</span><span style=3D"co=
lor: #000;" class=3D"styled-by-prettify"> s </span><span style=3D"color: #6=
60;" class=3D"styled-by-prettify"><<</span><span style=3D"color: #000=
;" class=3D"styled-by-prettify"> d </span><span style=3D"color: #660;" clas=
s=3D"styled-by-prettify"><<</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"> i</span><span style=3D"color: #660;" class=3D"styl=
ed-by-prettify">;</span><span style=3D"color: #000;" class=3D"styled-by-pre=
ttify"><br></span><span style=3D"color: #660;" class=3D"styled-by-prettify"=
>},</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> t</spa=
n><span style=3D"color: #660;" class=3D"styled-by-prettify">);</span><span =
style=3D"color: #000;" class=3D"styled-by-prettify"><br></span></div></code=
></div><div><br>Iterating over an associative container:</div><div><br></di=
v><div class=3D"prettyprint" style=3D"background-color: rgb(250, 250, 250);=
border: 1px solid rgb(187, 187, 187); word-wrap: break-word;"><code class=
=3D"prettyprint"><div class=3D"subprettyprint"><span style=3D"color: #000;"=
class=3D"styled-by-prettify">std</span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">::</span><span style=3D"color: #000;" class=3D"styl=
ed-by-prettify">map</span><span style=3D"color: #660;" class=3D"styled-by-p=
rettify"><</span><span style=3D"color: #008;" class=3D"styled-by-prettif=
y">int</span><span style=3D"color: #660;" class=3D"styled-by-prettify">,</s=
pan><span style=3D"color: #000;" class=3D"styled-by-prettify"> std</span><s=
pan style=3D"color: #660;" class=3D"styled-by-prettify">::</span><span styl=
e=3D"color: #008;" class=3D"styled-by-prettify">string</span><span style=3D=
"color: #660;" class=3D"styled-by-prettify">></span><span style=3D"color=
: #000;" class=3D"styled-by-prettify"> m</span><span style=3D"color: #660;"=
class=3D"styled-by-prettify">;</span><span style=3D"color: #000;" class=3D=
"styled-by-prettify"><br></span><span style=3D"color: #008;" class=3D"style=
d-by-prettify">for</span><span style=3D"color: #000;" class=3D"styled-by-pr=
ettify"> </span><span style=3D"color: #660;" class=3D"styled-by-prettify">(=
</span><span style=3D"color: #008;" class=3D"styled-by-prettify">auto</span=
><span style=3D"color: #660;" class=3D"styled-by-prettify">&&</span=
><span style=3D"color: #000;" class=3D"styled-by-prettify"> kv</span><span =
style=3D"color: #660;" class=3D"styled-by-prettify">:</span><span style=3D"=
color: #000;" class=3D"styled-by-prettify"> m</span><span style=3D"color: #=
660;" class=3D"styled-by-prettify">)</span><span style=3D"color: #000;" cla=
ss=3D"styled-by-prettify"> </span><span style=3D"color: #660;" class=3D"sty=
led-by-prettify">{</span><span style=3D"color: #000;" class=3D"styled-by-pr=
ettify"><br> apply</span><span style=3D"color: #660;" class=3D"styled=
-by-prettify">([&](</span><span style=3D"color: #008;" class=3D"styled-=
by-prettify">auto</span><span style=3D"color: #000;" class=3D"styled-by-pre=
ttify"> </span><span style=3D"color: #008;" class=3D"styled-by-prettify">co=
nst</span><span style=3D"color: #660;" class=3D"styled-by-prettify">&&a=
mp;</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> k</spa=
n><span style=3D"color: #660;" class=3D"styled-by-prettify">,</span><span s=
tyle=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"c=
olor: #008;" class=3D"styled-by-prettify">auto</span><span style=3D"color: =
#660;" class=3D"styled-by-prettify">&&</span><span style=3D"color: =
#000;" class=3D"styled-by-prettify"> v</span><span style=3D"color: #660;" c=
lass=3D"styled-by-prettify">)</span><span style=3D"color: #000;" class=3D"s=
tyled-by-prettify"> </span><span style=3D"color: #660;" class=3D"styled-by-=
prettify">{</span><span style=3D"color: #000;" class=3D"styled-by-prettify"=
><br> </span><span style=3D"color: #800;" class=3D"styled-by-p=
rettify">// ...</span><span style=3D"color: #000;" class=3D"styled-by-prett=
ify"><br> </span><span style=3D"color: #660;" class=3D"styled-by-pret=
tify">},</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> k=
v</span><span style=3D"color: #660;" class=3D"styled-by-prettify">);</span>=
<span style=3D"color: #000;" class=3D"styled-by-prettify"><br></span><span =
style=3D"color: #660;" class=3D"styled-by-prettify">}</span><span style=3D"=
color: #000;" class=3D"styled-by-prettify"><br></span></div></code></div><d=
iv><br>Any new syntax would have to represent a significant improvement ove=
r this, which seems a pretty tough bar to attain.</div><div><br></div><div>=
It would probably read better with the arguments in the opposite order, but=
it's trivial to write the equivalent of <font face=3D"courier new, monospa=
ce">unpack =3D flip apply</font>. One can even write an "unpacking operator=
" using everyone's favorite overloadable binary operator:</div><div><br></d=
iv><div><div class=3D"prettyprint" style=3D"background-color: rgb(250, 250,=
250); border: 1px solid rgb(187, 187, 187); word-wrap: break-word;"><code =
class=3D"prettyprint"><div class=3D"subprettyprint"><span style=3D"color: #=
008;" class=3D"styled-by-prettify">template</span><span style=3D"color: #66=
0;" class=3D"styled-by-prettify"><</span><span style=3D"color: #008;" cl=
ass=3D"styled-by-prettify">typename</span><span style=3D"color: #000;" clas=
s=3D"styled-by-prettify"> T</span><span style=3D"color: #660;" class=3D"sty=
led-by-prettify">,</span><span style=3D"color: #000;" class=3D"styled-by-pr=
ettify"> </span><span style=3D"color: #008;" class=3D"styled-by-prettify">t=
ypename</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> F<=
/span><span style=3D"color: #660;" class=3D"styled-by-prettify">></span>=
<span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span sty=
le=3D"color: #008;" class=3D"styled-by-prettify">decltype</span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">(</span><span style=3D"color=
: #008;" class=3D"styled-by-prettify">auto</span><span style=3D"color: #660=
;" class=3D"styled-by-prettify">)</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"> </span><span style=3D"color: #008;" class=3D"style=
d-by-prettify">operator</span><span style=3D"color: #660;" class=3D"styled-=
by-prettify">->*(</span><span style=3D"color: #000;" class=3D"styled-by-=
prettify">T</span><span style=3D"color: #660;" class=3D"styled-by-prettify"=
>&&</span><span style=3D"color: #000;" class=3D"styled-by-prettify"=
> t</span><span style=3D"color: #660;" class=3D"styled-by-prettify">,</span=
><span style=3D"color: #000;" class=3D"styled-by-prettify"> F</span><span s=
tyle=3D"color: #660;" class=3D"styled-by-prettify">&&</span><span s=
tyle=3D"color: #000;" class=3D"styled-by-prettify"> f</span><span style=3D"=
color: #660;" class=3D"styled-by-prettify">)</span><span style=3D"color: #0=
00;" class=3D"styled-by-prettify"> </span><span style=3D"color: #660;" clas=
s=3D"styled-by-prettify">{</span><span style=3D"color: #000;" class=3D"styl=
ed-by-prettify"><br> </span><span style=3D"color: #008;" class=3D"sty=
led-by-prettify">return</span><span style=3D"color: #000;" class=3D"styled-=
by-prettify"> std</span><span style=3D"color: #660;" class=3D"styled-by-pre=
ttify">::</span><span style=3D"color: #000;" class=3D"styled-by-prettify">a=
pply</span><span style=3D"color: #660;" class=3D"styled-by-prettify">(</spa=
n><span style=3D"color: #000;" class=3D"styled-by-prettify">std</span><span=
style=3D"color: #660;" class=3D"styled-by-prettify">::</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify">forward</span><span style=3D=
"color: #660;" class=3D"styled-by-prettify"><</span><span style=3D"color=
: #000;" class=3D"styled-by-prettify">F</span><span style=3D"color: #660;" =
class=3D"styled-by-prettify">>(</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify">f</span><span style=3D"color: #660;" class=3D"style=
d-by-prettify">),</span><span style=3D"color: #000;" class=3D"styled-by-pre=
ttify"> std</span><span style=3D"color: #660;" class=3D"styled-by-prettify"=
>::</span><span style=3D"color: #000;" class=3D"styled-by-prettify">forward=
</span><span style=3D"color: #660;" class=3D"styled-by-prettify"><</span=
><span style=3D"color: #000;" class=3D"styled-by-prettify">T</span><span st=
yle=3D"color: #660;" class=3D"styled-by-prettify">>(</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify">t</span><span style=3D"color=
: #660;" class=3D"styled-by-prettify">));</span><span style=3D"color: #000;=
" class=3D"styled-by-prettify"><br></span><span style=3D"color: #660;" clas=
s=3D"styled-by-prettify">}</span><span style=3D"color: #000;" class=3D"styl=
ed-by-prettify"><br><br></span><span style=3D"color: #008;" class=3D"styled=
-by-prettify">auto</span><span style=3D"color: #000;" class=3D"styled-by-pr=
ettify"> t </span><span style=3D"color: #660;" class=3D"styled-by-prettify"=
>=3D</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> std</=
span><span style=3D"color: #660;" class=3D"styled-by-prettify">::</span><sp=
an style=3D"color: #000;" class=3D"styled-by-prettify">make_tuple</span><sp=
an style=3D"color: #660;" class=3D"styled-by-prettify">(</span><span style=
=3D"color: #080;" class=3D"styled-by-prettify">"hello"</span><span style=3D=
"color: #660;" class=3D"styled-by-prettify">,</span><span style=3D"color: #=
000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #066;" cla=
ss=3D"styled-by-prettify">123.45</span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">,</span><span style=3D"color: #000;" class=3D"style=
d-by-prettify"> </span><span style=3D"color: #066;" class=3D"styled-by-pret=
tify">66</span><span style=3D"color: #660;" class=3D"styled-by-prettify">);=
</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br>t </sp=
an><span style=3D"color: #660;" class=3D"styled-by-prettify">->*</span><=
span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span styl=
e=3D"color: #660;" class=3D"styled-by-prettify">[&](</span><span style=
=3D"color: #008;" class=3D"styled-by-prettify">auto</span><span style=3D"co=
lor: #000;" class=3D"styled-by-prettify"> s</span><span style=3D"color: #66=
0;" class=3D"styled-by-prettify">,</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"> </span><span style=3D"color: #008;" class=3D"style=
d-by-prettify">auto</span><span style=3D"color: #000;" class=3D"styled-by-p=
rettify"> d</span><span style=3D"color: #660;" class=3D"styled-by-prettify"=
>,</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span>=
<span style=3D"color: #008;" class=3D"styled-by-prettify">auto</span><span =
style=3D"color: #000;" class=3D"styled-by-prettify"> i</span><span style=3D=
"color: #660;" class=3D"styled-by-prettify">)</span><span style=3D"color: #=
000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #660;" cla=
ss=3D"styled-by-prettify">{</span><span style=3D"color: #000;" class=3D"sty=
led-by-prettify"> </span><span style=3D"color: #800;" class=3D"styled=
-by-prettify">// t </span><span style=3D"color: #800;" class=3D"styled-by-p=
rettify">goes to s, d, and i</span><span style=3D"color: #000;" class=3D"st=
yled-by-prettify"><br> std</span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">::</span><span style=3D"color: #000;" class=3D"styl=
ed-by-prettify">cout </span><span style=3D"color: #660;" class=3D"styled-by=
-prettify"><<</span><span style=3D"color: #000;" class=3D"styled-by-p=
rettify"> s </span><span style=3D"color: #660;" class=3D"styled-by-prettify=
"><<</span><span style=3D"color: #000;" class=3D"styled-by-prettify">=
d </span><span style=3D"color: #660;" class=3D"styled-by-prettify"><<=
;</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> i</span>=
<span style=3D"color: #660;" class=3D"styled-by-prettify">;</span><span sty=
le=3D"color: #000;" class=3D"styled-by-prettify"><br></span><span style=3D"=
color: #660;" class=3D"styled-by-prettify">};</span><span style=3D"color: #=
000;" class=3D"styled-by-prettify"><br></span></div></code></div><div><br>(=
Heh.)</div></div></div>
<p></p>
-- <br />
<br />
--- <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 />
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/">http://groups.google.com/a/isocpp.org/group/std-proposals/<=
/a>.<br />
------=_Part_711_1377563527.1406761826023--
.
Author: David Krauss <potswa@gmail.com>
Date: Thu, 31 Jul 2014 07:22:28 +0800
Raw View
--Apple-Mail=_B6782DA9-EA82-41A4-B351-CEB567ED808F
Content-Transfer-Encoding: quoted-printable
Content-Type: text/plain; charset=ISO-8859-1
On 2014-07-30, at 10:29 PM, walter1234 <walter2bz@gmail.com> wrote:
> Would `struct` in an lvalue location work , directly analogous to the des=
tructuring in rust, just with sequential access allowed to named structs (s=
o they can be used like tuples in functional languages)
>=20
> eg=20
>=20
> struct { auto x,auto y,auto z } =3D std::make_tuple(1,2.0,"three"); =
//x=3D1, y=3D2.0, z=3D"three"
Note, this is similar to a C11 anonymous structure in syntax and semantics.=
The unpacked x, y, and z wouldn't need to be a new kind of entity. The "da=
mage" would be contained to initialization semantics, and there might be sy=
nergy with deduced class template arguments as well.
--=20
---=20
You received this message because you are subscribed to the Google Groups "=
ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposa=
ls/.
--Apple-Mail=_B6782DA9-EA82-41A4-B351-CEB567ED808F
Content-Transfer-Encoding: quoted-printable
Content-Type: text/html; charset=ISO-8859-1
<html><head><meta http-equiv=3D"Content-Type" content=3D"text/html charset=
=3Dwindows-1252"></head><body style=3D"word-wrap: break-word; -webkit-nbsp-=
mode: space; -webkit-line-break: after-white-space;"><br><div><div>On 2014&=
ndash;07–30, at 10:29 PM, walter1234 <<a href=3D"mailto:walter2bz@=
gmail.com">walter2bz@gmail.com</a>> wrote:</div><br class=3D"Apple-inter=
change-newline"><blockquote type=3D"cite"><div dir=3D"ltr"><font face=3D"ar=
ial, sans-serif">Would `struct` in an lvalue location work , directly analo=
gous to the destructuring in rust, just with sequential access allowed=
to named structs (so they can be used like tuples in functional langu=
ages)</font><div><font face=3D"arial, sans-serif"><br></font></div><div><fo=
nt face=3D"arial, sans-serif">eg </font></div><div><font face=3D"arial=
, sans-serif"><br></font></div><div><font face=3D"arial, sans-serif"> =
struct { auto x,auto y,auto z } =3D std::make_tuple(1,2.0,"thr=
ee"); //x=3D1, y=3D2.0, z=3D“three"</font></div></div></blockqu=
ote><div><br></div><div>Note, this is similar to a C11 anonymous structure =
in syntax and semantics. The unpacked x, y, and z wouldn’t need to be=
a new kind of entity. The “damage” would be contained to initi=
alization semantics, and there might be synergy with deduced class template=
arguments as well.</div></div><br></body></html>
<p></p>
-- <br />
<br />
--- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals" group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<br />
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/">http://groups.google.com/a/isocpp.org/group/std-proposals/<=
/a>.<br />
--Apple-Mail=_B6782DA9-EA82-41A4-B351-CEB567ED808F--
.
Author: inkwizytoryankes@gmail.com
Date: Fri, 1 Aug 2014 13:30:38 -0700 (PDT)
Raw View
------=_Part_530_1315772581.1406925038620
Content-Type: text/plain; charset=UTF-8
If you skip `auto` you can do somthing like this now:
template<typename Tuple>
struct cast_t
{
Tuple t;
template<typename T>
operator T()
{
return T{ std::get<0>(t), std::get<1>(t) /*... ect*/ };
}
};
template<typename Tuple>
cast_t<Tuple> cast(const Tuple& t)
{
return cast_t<Tuple>{ t };
}
int main()
{
struct { int a; int b; } z = cast(std::make_tuple(1, 2));
std::cout << z.a << " " << z.b << std::endl;
}
On Wednesday, July 30, 2014 4:29:34 PM UTC+2, walter1234 wrote:
>
> Would `struct` in an lvalue location work , directly analogous to the
> destructuring in rust, just with sequential access allowed to named structs
> (so they can be used like tuples in functional languages)
>
> eg
>
> struct { auto x,auto y,auto z } = std::make_tuple(1,2.0,"three");
> //x=1, y=2.0, z="three"
>
>
> Such a shame how simple brackets and commas already parse in C++.. the
> elegance of let (x,y)=... in rust is a big draw.
>
>
>
--
---
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_530_1315772581.1406925038620
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr">If you skip `auto` you can do somthing like this now:<br><=
div class=3D"prettyprint" style=3D"background-color: rgb(250, 250, 250); bo=
rder-color: rgb(187, 187, 187); border-style: solid; border-width: 1px; wor=
d-wrap: break-word;"><code class=3D"prettyprint"><div class=3D"subprettypri=
nt"><span style=3D"color: #000;" class=3D"styled-by-prettify"><br></span><s=
pan style=3D"color: #008;" class=3D"styled-by-prettify">template</span><spa=
n style=3D"color: #660;" class=3D"styled-by-prettify"><</span><span styl=
e=3D"color: #008;" class=3D"styled-by-prettify">typename</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color=
: #606;" class=3D"styled-by-prettify">Tuple</span><span style=3D"color: #66=
0;" class=3D"styled-by-prettify">></span><span style=3D"color: #000;" cl=
ass=3D"styled-by-prettify"><br></span><span style=3D"color: #008;" class=3D=
"styled-by-prettify">struct</span><span style=3D"color: #000;" class=3D"sty=
led-by-prettify"> cast_t<br></span><span style=3D"color: #660;" class=3D"st=
yled-by-prettify">{</span><span style=3D"color: #000;" class=3D"styled-by-p=
rettify"><br> </span><span style=3D"color: #606;" class=3D"styled-by-=
prettify">Tuple</span><span style=3D"color: #000;" class=3D"styled-by-prett=
ify"> t</span><span style=3D"color: #660;" class=3D"styled-by-prettify">;</=
span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br> <=
/span><span style=3D"color: #008;" class=3D"styled-by-prettify">template</s=
pan><span style=3D"color: #660;" class=3D"styled-by-prettify"><</span><s=
pan style=3D"color: #008;" class=3D"styled-by-prettify">typename</span><spa=
n style=3D"color: #000;" class=3D"styled-by-prettify"> T</span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">></span><span style=3D"co=
lor: #000;" class=3D"styled-by-prettify"><br> </span><span style=3D"c=
olor: #008;" class=3D"styled-by-prettify">operator</span><span style=3D"col=
or: #000;" class=3D"styled-by-prettify"> T</span><span style=3D"color: #660=
;" class=3D"styled-by-prettify">()</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"><br> </span><span style=3D"color: #660;" clas=
s=3D"styled-by-prettify">{</span><span style=3D"color: #000;" class=3D"styl=
ed-by-prettify"><br> </span><span style=3D"color: #008;" class=
=3D"styled-by-prettify">return</span><span style=3D"color: #000;" class=3D"=
styled-by-prettify"> T</span><span style=3D"color: #660;" class=3D"styled-b=
y-prettify">{</span><span style=3D"color: #000;" class=3D"styled-by-prettif=
y"> std</span><span style=3D"color: #660;" class=3D"styled-by-prettify">::<=
/span><span style=3D"color: #008;" class=3D"styled-by-prettify">get</span><=
span style=3D"color: #660;" class=3D"styled-by-prettify"><</span><span s=
tyle=3D"color: #066;" class=3D"styled-by-prettify">0</span><span style=3D"c=
olor: #660;" class=3D"styled-by-prettify">>(</span><span style=3D"color:=
#000;" class=3D"styled-by-prettify">t</span><span style=3D"color: #660;" c=
lass=3D"styled-by-prettify">),</span><span style=3D"color: #000;" class=3D"=
styled-by-prettify"> std</span><span style=3D"color: #660;" class=3D"styled=
-by-prettify">::</span><span style=3D"color: #008;" class=3D"styled-by-pret=
tify">get</span><span style=3D"color: #660;" class=3D"styled-by-prettify">&=
lt;</span><span style=3D"color: #066;" class=3D"styled-by-prettify">1</span=
><span style=3D"color: #660;" class=3D"styled-by-prettify">>(</span><spa=
n style=3D"color: #000;" class=3D"styled-by-prettify">t</span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">)</span><span style=3D"color=
: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #800;" =
class=3D"styled-by-prettify">/*... ect*/</span><span style=3D"color: #000;"=
class=3D"styled-by-prettify"> </span><span style=3D"color: #660;" class=3D=
"styled-by-prettify">};</span><span style=3D"color: #000;" class=3D"styled-=
by-prettify"><br> </span><span style=3D"color: #660;" class=3D"styled=
-by-prettify">}</span><span style=3D"color: #000;" class=3D"styled-by-prett=
ify"><br></span><span style=3D"color: #660;" class=3D"styled-by-prettify">}=
;</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br><br><=
/span><span style=3D"color: #008;" class=3D"styled-by-prettify">template</s=
pan><span style=3D"color: #660;" class=3D"styled-by-prettify"><</span><s=
pan style=3D"color: #008;" class=3D"styled-by-prettify">typename</span><spa=
n style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=
=3D"color: #606;" class=3D"styled-by-prettify">Tuple</span><span style=3D"c=
olor: #660;" class=3D"styled-by-prettify">></span><span style=3D"color: =
#000;" class=3D"styled-by-prettify"><br>cast_t</span><span style=3D"color: =
#660;" class=3D"styled-by-prettify"><</span><span style=3D"color: #606;"=
class=3D"styled-by-prettify">Tuple</span><span style=3D"color: #660;" clas=
s=3D"styled-by-prettify">></span><span style=3D"color: #000;" class=3D"s=
tyled-by-prettify"> cast</span><span style=3D"color: #660;" class=3D"styled=
-by-prettify">(</span><span style=3D"color: #008;" class=3D"styled-by-prett=
ify">const</span><span style=3D"color: #000;" class=3D"styled-by-prettify">=
</span><span style=3D"color: #606;" class=3D"styled-by-prettify">Tuple</sp=
an><span style=3D"color: #660;" class=3D"styled-by-prettify">&</span><s=
pan style=3D"color: #000;" class=3D"styled-by-prettify"> t</span><span styl=
e=3D"color: #660;" class=3D"styled-by-prettify">)</span><span style=3D"colo=
r: #000;" class=3D"styled-by-prettify"><br></span><span style=3D"color: #66=
0;" class=3D"styled-by-prettify">{</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"><br> </span><span style=3D"color: #008;" clas=
s=3D"styled-by-prettify">return</span><span style=3D"color: #000;" class=3D=
"styled-by-prettify"> cast_t</span><span style=3D"color: #660;" class=3D"st=
yled-by-prettify"><</span><span style=3D"color: #606;" class=3D"styled-b=
y-prettify">Tuple</span><span style=3D"color: #660;" class=3D"styled-by-pre=
ttify">>{</span><span style=3D"color: #000;" class=3D"styled-by-prettify=
"> t </span><span style=3D"color: #660;" class=3D"styled-by-prettify">};</s=
pan><span style=3D"color: #000;" class=3D"styled-by-prettify"><br></span><s=
pan style=3D"color: #660;" class=3D"styled-by-prettify">}</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"><br><br><br></span><span sty=
le=3D"color: #008;" class=3D"styled-by-prettify">int</span><span style=3D"c=
olor: #000;" class=3D"styled-by-prettify"> main</span><span style=3D"color:=
#660;" class=3D"styled-by-prettify">()</span><span style=3D"color: #000;" =
class=3D"styled-by-prettify"><br></span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">{</span><span style=3D"color: #000;" class=3D"style=
d-by-prettify"><br> </span><span style=3D"color: #008;" class=3D"styl=
ed-by-prettify">struct</span><span style=3D"color: #000;" class=3D"styled-b=
y-prettify"> </span><span style=3D"color: #660;" class=3D"styled-by-prettif=
y">{</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </spa=
n><span style=3D"color: #008;" class=3D"styled-by-prettify">int</span><span=
style=3D"color: #000;" class=3D"styled-by-prettify"> a</span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">;</span><span style=3D"color=
: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #008;" =
class=3D"styled-by-prettify">int</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"> b</span><span style=3D"color: #660;" class=3D"styl=
ed-by-prettify">;</span><span style=3D"color: #000;" class=3D"styled-by-pre=
ttify"> </span><span style=3D"color: #660;" class=3D"styled-by-prettify">}<=
/span><span style=3D"color: #000;" class=3D"styled-by-prettify"> z </span><=
span style=3D"color: #660;" class=3D"styled-by-prettify">=3D</span><span st=
yle=3D"color: #000;" class=3D"styled-by-prettify"> cast</span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">(</span><span style=3D"color=
: #000;" class=3D"styled-by-prettify">std</span><span style=3D"color: #660;=
" class=3D"styled-by-prettify">::</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify">make_tuple</span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">(</span><span style=3D"color: #066;" class=3D"style=
d-by-prettify">1</span><span style=3D"color: #660;" class=3D"styled-by-pret=
tify">,</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </=
span><span style=3D"color: #066;" class=3D"styled-by-prettify">2</span><spa=
n style=3D"color: #660;" class=3D"styled-by-prettify">));</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"><br> std</span><span s=
tyle=3D"color: #660;" class=3D"styled-by-prettify">::</span><span style=3D"=
color: #000;" class=3D"styled-by-prettify">cout </span><span style=3D"color=
: #660;" class=3D"styled-by-prettify"><<</span><span style=3D"color: =
#000;" class=3D"styled-by-prettify"> z</span><span style=3D"color: #660;" c=
lass=3D"styled-by-prettify">.</span><span style=3D"color: #000;" class=3D"s=
tyled-by-prettify">a </span><span style=3D"color: #660;" class=3D"styled-by=
-prettify"><<</span><span style=3D"color: #000;" class=3D"styled-by-p=
rettify"> </span><span style=3D"color: #080;" class=3D"styled-by-prettify">=
" "</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span=
><span style=3D"color: #660;" class=3D"styled-by-prettify"><<</span><=
span style=3D"color: #000;" class=3D"styled-by-prettify"> z</span><span sty=
le=3D"color: #660;" class=3D"styled-by-prettify">.</span><span style=3D"col=
or: #000;" class=3D"styled-by-prettify">b </span><span style=3D"color: #660=
;" class=3D"styled-by-prettify"><<</span><span style=3D"color: #000;"=
class=3D"styled-by-prettify"> std</span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">::</span><span style=3D"color: #000;" class=3D"styl=
ed-by-prettify">endl</span><span style=3D"color: #660;" class=3D"styled-by-=
prettify">;</span><span style=3D"color: #000;" class=3D"styled-by-prettify"=
><br></span><span style=3D"color: #660;" class=3D"styled-by-prettify">}</sp=
an><span style=3D"color: #000;" class=3D"styled-by-prettify"><br><br></span=
></div></code></div><br><br><br><br>On Wednesday, July 30, 2014 4:29:34 PM =
UTC+2, walter1234 wrote:<blockquote class=3D"gmail_quote" style=3D"margin: =
0;margin-left: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;"><div d=
ir=3D"ltr"><font color=3D"#000000" face=3D"arial, sans-serif">Would `struct=
` in an lvalue location work , directly analogous to the destructuring in r=
ust, just with sequential access allowed to named structs (so they can=
be used like tuples in functional languages)</font><div><font color=
=3D"#000000" face=3D"arial, sans-serif"><br></font></div><div><font color=
=3D"#000000" face=3D"arial, sans-serif">eg </font></div><div><font col=
or=3D"#000000" face=3D"arial, sans-serif"><br></font></div><div><font color=
=3D"#000000" face=3D"arial, sans-serif"> struct { auto x,=
auto y,auto z } =3D std::make_tuple(1,2.0,"three")<wbr>; //x=3D1, y=
=3D2.0, z=3D"three"</font></div><div><font color=3D"#000000" face=3D"arial,=
sans-serif"><br></font></div><div><font color=3D"#000000" face=3D"arial, s=
ans-serif"><br></font></div><div><font color=3D"#000000" face=3D"arial, san=
s-serif">Such a shame how simple brackets and commas already parse in =
C++.. the elegance of let (x,y)=3D... in rust is a big draw.</font></div><d=
iv><font color=3D"#000000" face=3D"arial, sans-serif"><br></font></div><div=
><font color=3D"#000000" face=3D"arial, sans-serif"><br></font></div></div>=
</blockquote></div>
<p></p>
-- <br />
<br />
--- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals" group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<br />
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/">http://groups.google.com/a/isocpp.org/group/std-proposals/<=
/a>.<br />
------=_Part_530_1315772581.1406925038620--
.
Author: snk_kid <korcan.hussein@googlemail.com>
Date: Sat, 2 Aug 2014 02:26:32 -0700 (PDT)
Raw View
------=_Part_565_1582307158.1406971592732
Content-Type: text/plain; charset=UTF-8
On Thursday, July 31, 2014 12:10:26 AM UTC+1, Edward Catmur wrote:
>
>
> Any new syntax would have to represent a significant improvement over
> this, which seems a pretty tough bar to attain.
>
I believe it's an easy bar to attain over that example and *syntactically *your
example doesn't generalize well to nested tuples, it will get ugly pretty
quickly.
std::map<int, std::string> m;
// tuple pattern, 1st & 2nd elements are bound to the variable 'k' & 'v'
for (auto (k,v) : m)
{}
or
std::map<int, std::string> m;
// tuple pattern, 1st element is bound to the variable 'k', 2nd element is
ignored.
for (auto (k,_) : m)
{}
or
std::map<int, std::string> m;
// tuple pattern, 2nd element is bound to the variable 'v', 1st element is
ignored.
for (auto (_,v) : m)
{}
or getting fancy
std::map<int, std::string> m;
// tuple pattern, 2nd element is bound to the variable 'v', 1st element is
ignored.
// 't' binds to the tuple itself.
for (auto (t@(_,v)) : m)
{}
or nested tuple example:
std::map<int, std::tuple<int, std::string> > m;
for (auto (_,(_,v)) : m)
{}
In my eyes there is no competition compared to pattern matching (+ type
inference) as a built-in language feature.
--
---
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_565_1582307158.1406971592732
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr"><br>On Thursday, July 31, 2014 12:10:26 AM UTC+1, Edward C=
atmur wrote:<blockquote class=3D"gmail_quote" style=3D"margin: 0;margin-lef=
t: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;"><div><br><div>Any =
new syntax would have to represent a significant improvement over this, whi=
ch seems a pretty tough bar to attain.</div></div></blockquote><div><br>I b=
elieve it's an easy bar to attain over that example and <b>syntactically </=
b>your example doesn't generalize well to nested tuples, it will get ugly p=
retty quickly.<br></div><div><br><div class=3D"prettyprint" style=3D"backgr=
ound-color: rgb(250, 250, 250); border-color: rgb(187, 187, 187); border-st=
yle: solid; border-width: 1px; word-wrap: break-word;"><code class=3D"prett=
yprint"><div class=3D"subprettyprint"><div style=3D"background-color:rgb(25=
0,250,250);border:1px solid rgb(187,187,187);word-wrap:break-word"><code><d=
iv><span style=3D"color:#000"><span style=3D"color: #000;" class=3D"styled-=
by-prettify">std</span></span><span style=3D"color:#660"><span style=3D"col=
or: #660;" class=3D"styled-by-prettify">::</span></span><span style=3D"colo=
r:#000"><span style=3D"color: #000;" class=3D"styled-by-prettify">map</span=
></span><span style=3D"color:#660"><span style=3D"color: #660;" class=3D"st=
yled-by-prettify"><</span></span><span style=3D"color:#008"><span style=
=3D"color: #008;" class=3D"styled-by-prettify">int</span></span><span style=
=3D"color:#660"><span style=3D"color: #660;" class=3D"styled-by-prettify">,=
</span></span><span style=3D"color:#000"><span style=3D"color: #000;" class=
=3D"styled-by-prettify"> std</span></span><span style=3D"color:#660"><span =
style=3D"color: #660;" class=3D"styled-by-prettify">::</span></span><span s=
tyle=3D"color:#008"><span style=3D"color: #008;" class=3D"styled-by-prettif=
y">string</span></span><span style=3D"color:#660"><span style=3D"color: #66=
0;" class=3D"styled-by-prettify">></span></span><span style=3D"color:#00=
0"><span style=3D"color: #000;" class=3D"styled-by-prettify"> m</span></spa=
n><span style=3D"color:#660"><span style=3D"color: #660;" class=3D"styled-b=
y-prettify">;</span></span><span style=3D"color:#000"><span style=3D"color:=
#000;" class=3D"styled-by-prettify"><br></span><span style=3D"color: #000;=
" class=3D"styled-by-prettify"></span></span><code class=3D"prettyprint"><c=
ode><span style=3D"color:#660"><span style=3D"color: #800;" class=3D"styled=
-by-prettify">// tuple pattern, 1st & 2nd elements are bound to the var=
iable 'k' & 'v'</span><span style=3D"color: #000;" class=3D"styled-by-p=
rettify"><br></span></span></code></code><span style=3D"color:#008"><span s=
tyle=3D"color: #008;" class=3D"styled-by-prettify">for</span></span><span s=
tyle=3D"color:#000"><span style=3D"color: #000;" class=3D"styled-by-prettif=
y"> </span></span><span style=3D"color:#660"><span style=3D"color: #660;" c=
lass=3D"styled-by-prettify">(</span></span><span style=3D"color:#008"><span=
style=3D"color: #008;" class=3D"styled-by-prettify">auto</span></span><spa=
n style=3D"color:#000"><span style=3D"color: #000;" class=3D"styled-by-pret=
tify"> </span><span style=3D"color: #660;" class=3D"styled-by-prettify">(</=
span><span style=3D"color: #000;" class=3D"styled-by-prettify">k</span><spa=
n style=3D"color: #660;" class=3D"styled-by-prettify">,</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify">v</span><span style=3D"color=
: #660;" class=3D"styled-by-prettify">)</span><span style=3D"color: #000;" =
class=3D"styled-by-prettify"> </span></span><span style=3D"color:#660"><spa=
n style=3D"color: #660;" class=3D"styled-by-prettify">:</span></span><span =
style=3D"color:#000"><span style=3D"color: #000;" class=3D"styled-by-pretti=
fy"> m</span></span><span style=3D"color:#660"><span style=3D"color: #660;"=
class=3D"styled-by-prettify">)</span></span><span style=3D"color:#660"><sp=
an style=3D"color: #000;" class=3D"styled-by-prettify"> <br></span><span st=
yle=3D"color: #660;" class=3D"styled-by-prettify">{</span></span><span styl=
e=3D"color:#660"><span style=3D"color: #660;" class=3D"styled-by-prettify">=
}</span></span><span style=3D"color:#000"><span style=3D"color: #000;" clas=
s=3D"styled-by-prettify"><br></span></span></div></code></div></div></code>=
</div><br>or<br><br><div class=3D"prettyprint" style=3D"background-color: r=
gb(250, 250, 250); border-color: rgb(187, 187, 187); border-style: solid; b=
order-width: 1px; word-wrap: break-word;"><code class=3D"prettyprint"><div =
class=3D"subprettyprint"><div class=3D"prettyprint" style=3D"background-col=
or: rgb(250, 250, 250); border-color: rgb(187, 187, 187); border-style: sol=
id; border-width: 1px; word-wrap: break-word;"><code class=3D"prettyprint">=
<div class=3D"subprettyprint"><div style=3D"background-color:rgb(250,250,25=
0);border:1px solid rgb(187,187,187);word-wrap:break-word"><code><div><span=
style=3D"color:#000"><span style=3D"color: #000;" class=3D"styled-by-prett=
ify">std</span></span><span style=3D"color:#660"><span style=3D"color: #660=
;" class=3D"styled-by-prettify">::</span></span><span style=3D"color:#000">=
<span style=3D"color: #000;" class=3D"styled-by-prettify">map</span></span>=
<span style=3D"color:#660"><span style=3D"color: #660;" class=3D"styled-by-=
prettify"><</span></span><span style=3D"color:#008"><span style=3D"color=
: #008;" class=3D"styled-by-prettify">int</span></span><span style=3D"color=
:#660"><span style=3D"color: #660;" class=3D"styled-by-prettify">,</span></=
span><span style=3D"color:#000"><span style=3D"color: #000;" class=3D"style=
d-by-prettify"> std</span></span><span style=3D"color:#660"><span style=3D"=
color: #660;" class=3D"styled-by-prettify">::</span></span><span style=3D"c=
olor:#008"><span style=3D"color: #008;" class=3D"styled-by-prettify">string=
</span></span><span style=3D"color:#660"><span style=3D"color: #660;" class=
=3D"styled-by-prettify">></span></span><span style=3D"color:#000"><span =
style=3D"color: #000;" class=3D"styled-by-prettify"> m</span></span><span s=
tyle=3D"color:#660"><span style=3D"color: #660;" class=3D"styled-by-prettif=
y">;</span></span><span style=3D"color:#000"><span style=3D"color: #000;" c=
lass=3D"styled-by-prettify"><br></span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"></span></span><code class=3D"prettyprint"><code><sp=
an style=3D"color:#660"><span style=3D"color: #800;" class=3D"styled-by-pre=
ttify">// tuple pattern, 1st element is bound to the variable 'k', 2nd elem=
ent is ignored.</span><span style=3D"color: #000;" class=3D"styled-by-prett=
ify"><br></span></span></code></code><span style=3D"color:#008"><span style=
=3D"color: #008;" class=3D"styled-by-prettify">for</span></span><span style=
=3D"color:#000"><span style=3D"color: #000;" class=3D"styled-by-prettify"> =
</span></span><span style=3D"color:#660"><span style=3D"color: #660;" class=
=3D"styled-by-prettify">(</span></span><span style=3D"color:#008"><span sty=
le=3D"color: #008;" class=3D"styled-by-prettify">auto</span></span><span st=
yle=3D"color:#000"><span style=3D"color: #000;" class=3D"styled-by-prettify=
"> </span><span style=3D"color: #660;" class=3D"styled-by-prettify">(</span=
><span style=3D"color: #000;" class=3D"styled-by-prettify">k</span><span st=
yle=3D"color: #660;" class=3D"styled-by-prettify">,_</span><span style=3D"c=
olor: #000;" class=3D"styled-by-prettify"></span><span style=3D"color: #660=
;" class=3D"styled-by-prettify">)</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"> </span></span><span style=3D"color:#660"><span sty=
le=3D"color: #660;" class=3D"styled-by-prettify">:</span></span><span style=
=3D"color:#000"><span style=3D"color: #000;" class=3D"styled-by-prettify"> =
m</span></span><span style=3D"color:#660"><span style=3D"color: #660;" clas=
s=3D"styled-by-prettify">)</span></span><span style=3D"color:#660"><span st=
yle=3D"color: #000;" class=3D"styled-by-prettify"> <br></span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">{</span></span><span style=
=3D"color:#000"></span><span style=3D"color:#660"><span style=3D"color: #66=
0;" class=3D"styled-by-prettify">}</span></span><span style=3D"color:#000">=
<span style=3D"color: #000;" class=3D"styled-by-prettify"><br></span></span=
></div></code></div></div></code></div><span style=3D"color: #660;" class=
=3D"styled-by-prettify"></span></div></code></div><br>or<br><br><div class=
=3D"prettyprint" style=3D"background-color: rgb(250, 250, 250); border-colo=
r: rgb(187, 187, 187); border-style: solid; border-width: 1px; word-wrap: b=
reak-word;"><code class=3D"prettyprint"><div class=3D"subprettyprint"><div =
class=3D"prettyprint" style=3D"background-color: rgb(250, 250, 250); border=
-color: rgb(187, 187, 187); border-style: solid; border-width: 1px; word-wr=
ap: break-word;"><code class=3D"prettyprint"><div class=3D"subprettyprint">=
<div style=3D"background-color:rgb(250,250,250);border:1px solid rgb(187,18=
7,187);word-wrap:break-word"><code><div><span style=3D"color:#000"><span st=
yle=3D"color: #000;" class=3D"styled-by-prettify">std</span></span><span st=
yle=3D"color:#660"><span style=3D"color: #660;" class=3D"styled-by-prettify=
">::</span></span><span style=3D"color:#000"><span style=3D"color: #000;" c=
lass=3D"styled-by-prettify">map</span></span><span style=3D"color:#660"><sp=
an style=3D"color: #660;" class=3D"styled-by-prettify"><</span></span><s=
pan style=3D"color:#008"><span style=3D"color: #008;" class=3D"styled-by-pr=
ettify">int</span></span><span style=3D"color:#660"><span style=3D"color: #=
660;" class=3D"styled-by-prettify">,</span></span><span style=3D"color:#000=
"><span style=3D"color: #000;" class=3D"styled-by-prettify"> std</span></sp=
an><span style=3D"color:#660"><span style=3D"color: #660;" class=3D"styled-=
by-prettify">::</span></span><span style=3D"color:#008"><span style=3D"colo=
r: #008;" class=3D"styled-by-prettify">string</span></span><span style=3D"c=
olor:#660"><span style=3D"color: #660;" class=3D"styled-by-prettify">></=
span></span><span style=3D"color:#000"><span style=3D"color: #000;" class=
=3D"styled-by-prettify"> m</span></span><span style=3D"color:#660"><span st=
yle=3D"color: #660;" class=3D"styled-by-prettify">;</span></span><span styl=
e=3D"color:#000"><span style=3D"color: #000;" class=3D"styled-by-prettify">=
<br></span><span style=3D"color: #000;" class=3D"styled-by-prettify"></span=
></span><code class=3D"prettyprint"><code><span style=3D"color:#660"><span =
style=3D"color: #800;" class=3D"styled-by-prettify">// tuple pattern, 2nd e=
lement is bound to the variable 'v', 1st element is ignored.</span><span st=
yle=3D"color: #000;" class=3D"styled-by-prettify"><br></span></span></code>=
</code><span style=3D"color:#008"><span style=3D"color: #008;" class=3D"sty=
led-by-prettify">for</span></span><span style=3D"color:#000"><span style=3D=
"color: #000;" class=3D"styled-by-prettify"> </span></span><span style=3D"c=
olor:#660"><span style=3D"color: #660;" class=3D"styled-by-prettify">(</spa=
n></span><span style=3D"color:#008"><span style=3D"color: #008;" class=3D"s=
tyled-by-prettify">auto</span></span><span style=3D"color:#000"><span style=
=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color=
: #660;" class=3D"styled-by-prettify">(</span><span style=3D"color: #000;" =
class=3D"styled-by-prettify">_</span><span style=3D"color: #660;" class=3D"=
styled-by-prettify">,v</span><span style=3D"color: #000;" class=3D"styled-b=
y-prettify"></span><span style=3D"color: #660;" class=3D"styled-by-prettify=
">)</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span=
></span><span style=3D"color:#660"><span style=3D"color: #660;" class=3D"st=
yled-by-prettify">:</span></span><span style=3D"color:#000"><span style=3D"=
color: #000;" class=3D"styled-by-prettify"> m</span></span><span style=3D"c=
olor:#660"><span style=3D"color: #660;" class=3D"styled-by-prettify">)</spa=
n></span><span style=3D"color:#660"><span style=3D"color: #000;" class=3D"s=
tyled-by-prettify"> <br></span><span style=3D"color: #660;" class=3D"styled=
-by-prettify">{</span></span><span style=3D"color:#000"></span><span style=
=3D"color:#660"><span style=3D"color: #660;" class=3D"styled-by-prettify">}=
</span></span><span style=3D"color:#000"><span style=3D"color: #000;" class=
=3D"styled-by-prettify"><br></span></span></div></code></div></div></code><=
/div><span style=3D"color: #660;" class=3D"styled-by-prettify"></span></div=
></code></div><br>or getting fancy<br><br><code class=3D"prettyprint"><div =
class=3D"prettyprint" style=3D"background-color: rgb(250, 250, 250); border=
-color: rgb(187, 187, 187); border-style: solid; border-width: 1px; word-wr=
ap: break-word;"><code class=3D"prettyprint"><div class=3D"subprettyprint">=
<div style=3D"background-color:rgb(250,250,250);border:1px solid rgb(187,18=
7,187);word-wrap:break-word"><code><div><span style=3D"color:#000"><span st=
yle=3D"color: #000;" class=3D"styled-by-prettify">std</span></span><span st=
yle=3D"color:#660"><span style=3D"color: #660;" class=3D"styled-by-prettify=
">::</span></span><span style=3D"color:#000"><span style=3D"color: #000;" c=
lass=3D"styled-by-prettify">map</span></span><span style=3D"color:#660"><sp=
an style=3D"color: #660;" class=3D"styled-by-prettify"><</span></span><s=
pan style=3D"color:#008"><span style=3D"color: #008;" class=3D"styled-by-pr=
ettify">int</span></span><span style=3D"color:#660"><span style=3D"color: #=
660;" class=3D"styled-by-prettify">,</span></span><span style=3D"color:#000=
"><span style=3D"color: #000;" class=3D"styled-by-prettify"> std</span></sp=
an><span style=3D"color:#660"><span style=3D"color: #660;" class=3D"styled-=
by-prettify">::</span></span><span style=3D"color:#008"><span style=3D"colo=
r: #008;" class=3D"styled-by-prettify">string</span></span><span style=3D"c=
olor:#660"><span style=3D"color: #660;" class=3D"styled-by-prettify">></=
span></span><span style=3D"color:#000"><span style=3D"color: #000;" class=
=3D"styled-by-prettify"> m</span></span><span style=3D"color:#660"><span st=
yle=3D"color: #660;" class=3D"styled-by-prettify">;</span></span><span styl=
e=3D"color:#000"><span style=3D"color: #000;" class=3D"styled-by-prettify">=
<br></span><span style=3D"color: #000;" class=3D"styled-by-prettify"></span=
></span><code class=3D"prettyprint"><code><span style=3D"color:#660"><span =
style=3D"color: #800;" class=3D"styled-by-prettify">// tuple pattern, 2nd e=
lement is bound to the variable 'v', 1st element is ignored.</span><span st=
yle=3D"color: #000;" class=3D"styled-by-prettify"><br>// 't' binds to the t=
uple itself.<br></span></span></code></code><span style=3D"color:#008"><spa=
n style=3D"color: #008;" class=3D"styled-by-prettify">for</span></span><spa=
n style=3D"color:#000"><span style=3D"color: #000;" class=3D"styled-by-pret=
tify"> </span></span><span style=3D"color:#660"><span style=3D"color: #660;=
" class=3D"styled-by-prettify">(</span></span><span style=3D"color:#008"><s=
pan style=3D"color: #008;" class=3D"styled-by-prettify">auto</span></span><=
span style=3D"color:#000"><span style=3D"color: #000;" class=3D"styled-by-p=
rettify"> </span><span style=3D"color: #660;" class=3D"styled-by-prettify">=
(t@(</span><span style=3D"color: #000;" class=3D"styled-by-prettify">_</spa=
n><span style=3D"color: #660;" class=3D"styled-by-prettify">,v</span><span =
style=3D"color: #000;" class=3D"styled-by-prettify"></span><span style=3D"c=
olor: #660;" class=3D"styled-by-prettify">))</span><span style=3D"color: #0=
00;" class=3D"styled-by-prettify"> </span></span><span style=3D"color:#660"=
><span style=3D"color: #660;" class=3D"styled-by-prettify">:</span></span><=
span style=3D"color:#000"><span style=3D"color: #000;" class=3D"styled-by-p=
rettify"> m</span></span><span style=3D"color:#660"><span style=3D"color: #=
660;" class=3D"styled-by-prettify">)</span></span><span style=3D"color:#660=
"><span style=3D"color: #000;" class=3D"styled-by-prettify"> <br></span><sp=
an style=3D"color: #660;" class=3D"styled-by-prettify">{</span></span><span=
style=3D"color:#000"></span><span style=3D"color:#660"><span style=3D"colo=
r: #660;" class=3D"styled-by-prettify">}</span></span><span style=3D"color:=
#000"><span style=3D"color: #000;" class=3D"styled-by-prettify"><br></span>=
</span></div></code></div></div></code></div></code><br>or nested tuple exa=
mple:<br><br><code class=3D"prettyprint"><div class=3D"prettyprint" style=
=3D"background-color: rgb(250, 250, 250); border-color: rgb(187, 187, 187);=
border-style: solid; border-width: 1px; word-wrap: break-word;"><code clas=
s=3D"prettyprint"><div class=3D"subprettyprint"><div style=3D"background-co=
lor:rgb(250,250,250);border:1px solid rgb(187,187,187);word-wrap:break-word=
"><code><div><span style=3D"color:#000"><span style=3D"color: #000;" class=
=3D"styled-by-prettify">std</span></span><span style=3D"color:#660"><span s=
tyle=3D"color: #660;" class=3D"styled-by-prettify">::</span></span><span st=
yle=3D"color:#000"><span style=3D"color: #000;" class=3D"styled-by-prettify=
">map</span></span><span style=3D"color:#660"><span style=3D"color: #660;" =
class=3D"styled-by-prettify"><</span></span><span style=3D"color:#008"><=
span style=3D"color: #008;" class=3D"styled-by-prettify">int</span></span><=
span style=3D"color:#660"><span style=3D"color: #660;" class=3D"styled-by-p=
rettify">,</span></span><span style=3D"color:#000"><span style=3D"color: #0=
00;" class=3D"styled-by-prettify"> std::tuple<int, std</span></span><spa=
n style=3D"color:#660"><span style=3D"color: #660;" class=3D"styled-by-pret=
tify">::</span></span><span style=3D"color:#008"><span style=3D"color: #008=
;" class=3D"styled-by-prettify">string</span></span><span style=3D"color:#6=
60"><span style=3D"color: #660;" class=3D"styled-by-prettify">> ></sp=
an></span><span style=3D"color:#000"><span style=3D"color: #000;" class=3D"=
styled-by-prettify"> m</span></span><span style=3D"color:#660"><span style=
=3D"color: #660;" class=3D"styled-by-prettify">;</span></span><code class=
=3D"prettyprint"><code><span style=3D"color:#660"><span style=3D"color: #00=
0;" class=3D"styled-by-prettify"><br></span></span></code></code><span styl=
e=3D"color:#008"><span style=3D"color: #008;" class=3D"styled-by-prettify">=
for</span></span><span style=3D"color:#000"><span style=3D"color: #000;" cl=
ass=3D"styled-by-prettify"> </span></span><span style=3D"color:#660"><span =
style=3D"color: #660;" class=3D"styled-by-prettify">(</span></span><span st=
yle=3D"color:#008"><span style=3D"color: #008;" class=3D"styled-by-prettify=
">auto</span></span><span style=3D"color:#000"><span style=3D"color: #000;"=
class=3D"styled-by-prettify"> </span><span style=3D"color: #660;" class=3D=
"styled-by-prettify">(_</span><span style=3D"color: #000;" class=3D"styled-=
by-prettify"></span><span style=3D"color: #660;" class=3D"styled-by-prettif=
y">,(_,v)</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><=
/span><span style=3D"color: #660;" class=3D"styled-by-prettify">)</span><sp=
an style=3D"color: #000;" class=3D"styled-by-prettify"> </span></span><span=
style=3D"color:#660"><span style=3D"color: #660;" class=3D"styled-by-prett=
ify">:</span></span><span style=3D"color:#000"><span style=3D"color: #000;"=
class=3D"styled-by-prettify"> m</span></span><span style=3D"color:#660"><s=
pan style=3D"color: #660;" class=3D"styled-by-prettify">)</span></span><spa=
n style=3D"color:#660"><span style=3D"color: #000;" class=3D"styled-by-pret=
tify"> </span></span><span style=3D"color:#660"><span style=3D"color: #000;=
" class=3D"styled-by-prettify"><code class=3D"prettyprint"><code class=3D"p=
rettyprint"><code><code class=3D"prettyprint"><code><span style=3D"color:#6=
60"><span style=3D"color: #000;" class=3D"styled-by-prettify"><br></span></=
span></code></code></code></code></code></span><span style=3D"color: #660;"=
class=3D"styled-by-prettify">{</span></span><span style=3D"color:#000"></s=
pan><span style=3D"color:#660"><span style=3D"color: #660;" class=3D"styled=
-by-prettify">}</span></span><span style=3D"color:#000"><span style=3D"colo=
r: #000;" class=3D"styled-by-prettify"><br></span></span></div></code></div=
></div></code></div></code><br>In my eyes there is no competition compared =
to pattern matching (+ type inference) as a built-in language feature.<br><=
/div></div>
<p></p>
-- <br />
<br />
--- <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 />
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/">http://groups.google.com/a/isocpp.org/group/std-proposals/<=
/a>.<br />
------=_Part_565_1582307158.1406971592732--
.