Topic: constexpr-specified loop variable
Author: Andrew Tomazos <andrewtomazos@gmail.com>
Date: Thu, 3 Oct 2013 07:09:21 -0700 (PDT)
Raw View
------=_Part_159_16229388.1380809361155
Content-Type: text/plain; charset=ISO-8859-1
The following is ill-formed:
template<int x> void f() {}
int main()
{
for (constexpr int x : {1,2,3})
f<x>();
}
as constexpr cannot specify a loop variable.
Maybe we could say:
for (constexpr T t : L)
is well-formed iff:
constexpr T[] arr = L
is well-formed. The semantics are as if the loop is unrolled in the
obvious way.
So for the original example it is as if:
int main()
{
{
constexpr int x = 1;
f<x>();
}
{
constexpr int x = 2;
f<x>();
}
{
constexpr int x = 3;
f<x>();
}
}
--
---
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_159_16229388.1380809361155
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr">The following is ill-formed:<br><br><div style=3D"margin-l=
eft: 40px;"><span style=3D"font-family: courier new,monospace;">template<=
;int x> void f() {}</span><br><span style=3D"font-family: courier new,mo=
nospace;"></span><br><span style=3D"font-family: courier new,monospace;">in=
t main()</span><br><span style=3D"font-family: courier new,monospace;">{</s=
pan><br><span style=3D"font-family: courier new,monospace;"> &nb=
sp; for (constexpr int x : {1,2,3})</span><br><span style=3D"font-family: c=
ourier new,monospace;"> f<x>();<=
/span><br><span style=3D"font-family: courier new,monospace;">}</span><br><=
span style=3D"font-family: courier new,monospace;"></span></div><span style=
=3D"font-family: courier new,monospace;"><br></span>as <span style=3D"font-=
family: courier new,monospace;">constexpr</span> cannot specify a loop vari=
able.<br><br>Maybe we could say:<br><br><div style=3D"margin-left: 40px;"><=
span style=3D"font-family: courier new,monospace;">for (constexpr T t : L)<=
br></span></div><br>is well-formed iff:<br><br><div style=3D"margin-left: 4=
0px;"><span style=3D"font-family: courier new,monospace;">constexpr T[] arr=
=3D L</span><br><span style=3D"font-family: courier new,monospace;"></span=
></div><br>is well-formed. The semantics are as if the loop is unroll=
ed in the obvious way.<br><br>So for the original example it is as if:<br><=
span style=3D"font-family: courier new,monospace;"><br></span><span style=
=3D"font-family: courier new,monospace;"> int main()</spa=
n><br><span style=3D"font-family: courier new,monospace;"></span><span styl=
e=3D"font-family: courier new,monospace;"> {<br></span><s=
pan style=3D"font-family: courier new,monospace;"> &=
nbsp; {<br> &nbs=
p; constexpr int x =3D 1;<br> &nbs=
p; f<x>();<br> &=
nbsp; }</span><br><span style=3D"font-family: courier new,monos=
pace;"> {<br> &n=
bsp; constexpr int x =3D 2;<br>&n=
bsp; f<x>=
();<br> }</span><br><span style=
=3D"font-family: courier new,monospace;"> &nbs=
p; {<br> &=
nbsp; constexpr int x =3D 3;<br> &=
nbsp; f<x>();<br> &nbs=
p; }</span><br><span style=3D"font-family: courier new,monospace;">&n=
bsp; }<br><br></span></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_159_16229388.1380809361155--
.
Author: Andrew Tomazos <andrewtomazos@gmail.com>
Date: Thu, 3 Oct 2013 07:10:30 -0700 (PDT)
Raw View
------=_Part_4415_11124057.1380809430464
Content-Type: text/plain; charset=ISO-8859-1
Typo:
constexpr T arr[] = L
On Thursday, October 3, 2013 4:09:21 PM UTC+2, Andrew Tomazos wrote:
>
> The following is ill-formed:
>
> template<int x> void f() {}
>
> int main()
> {
> for (constexpr int x : {1,2,3})
> f<x>();
> }
>
> as constexpr cannot specify a loop variable.
>
> Maybe we could say:
>
> for (constexpr T t : L)
>
> is well-formed iff:
>
> constexpr T[] arr = L
>
> is well-formed. The semantics are as if the loop is unrolled in the
> obvious way.
>
> So for the original example it is as if:
>
> int main()
> {
> {
> constexpr int x = 1;
> f<x>();
> }
> {
> constexpr int x = 2;
> f<x>();
> }
> {
> constexpr int x = 3;
> f<x>();
> }
> }
>
>
--
---
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_4415_11124057.1380809430464
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr">Typo:<br><br><span style=3D"font-family:courier new,monosp=
ace"> constexpr T arr[] =3D L</span><br><br>On Thursday, =
October 3, 2013 4:09:21 PM UTC+2, Andrew Tomazos wrote:<blockquote class=3D=
"gmail_quote" style=3D"margin: 0;margin-left: 0.8ex;border-left: 1px #ccc s=
olid;padding-left: 1ex;"><div dir=3D"ltr">The following is ill-formed:<br><=
br><div style=3D"margin-left:40px"><span style=3D"font-family:courier new,m=
onospace">template<int x> void f() {}</span><br><span style=3D"font-f=
amily:courier new,monospace"></span><br><span style=3D"font-family:courier =
new,monospace">int main()</span><br><span style=3D"font-family:courier new,=
monospace">{</span><br><span style=3D"font-family:courier new,monospace">&n=
bsp; for (constexpr int x : {1,2,3})</span><br><span style=3D"f=
ont-family:courier new,monospace"> f&l=
t;x>();</span><br><span style=3D"font-family:courier new,monospace">}</s=
pan><br><span style=3D"font-family:courier new,monospace"></span></div><spa=
n style=3D"font-family:courier new,monospace"><br></span>as <span style=3D"=
font-family:courier new,monospace">constexpr</span> cannot specify a loop v=
ariable.<br><br>Maybe we could say:<br><br><div style=3D"margin-left:40px">=
<span style=3D"font-family:courier new,monospace">for (constexpr T t : L)<b=
r></span></div><br>is well-formed iff:<br><br><div style=3D"margin-left:40p=
x"><span style=3D"font-family:courier new,monospace">constexpr T[] arr =3D =
L</span><br><span style=3D"font-family:courier new,monospace"></span></div>=
<br>is well-formed. The semantics are as if the loop is unrolled in t=
he obvious way.<br><br>So for the original example it is as if:<br><span st=
yle=3D"font-family:courier new,monospace"><br></span><span style=3D"font-fa=
mily:courier new,monospace"> int main()</span><br><span s=
tyle=3D"font-family:courier new,monospace"></span><span style=3D"font-famil=
y:courier new,monospace"> {<br></span><span style=3D"font=
-family:courier new,monospace"> {=
<br> cons=
texpr int x =3D 1;<br>  =
; f<x>();<br> }=
</span><br><span style=3D"font-family:courier new,monospace"> &n=
bsp; {<br>  =
; constexpr int x =3D 2;<br>  =
; f<x>();<br> &n=
bsp; }</span><br><span style=3D"font-family:courier=
new,monospace"> {<br>  =
; constexpr int x =3D=
3;<br> f=
<x>();<br> }</span><br><spa=
n style=3D"font-family:courier new,monospace"> }<br><br><=
/span></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 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_4415_11124057.1380809430464--
.
Author: =?ISO-8859-1?Q?Daniel_Kr=FCgler?= <daniel.kruegler@gmail.com>
Date: Thu, 3 Oct 2013 16:22:48 +0200
Raw View
2013/10/3 Andrew Tomazos <andrewtomazos@gmail.com>:
> The following is ill-formed:
>
> template<int x> void f() {}
>
> int main()
> {
> for (constexpr int x : {1,2,3})
> f<x>();
> }
>
> as constexpr cannot specify a loop variable.
This is not true, see [stmt.ranged] p2:
"In the decl-specifier-seq of a for-range-declaration, each
decl-specifier shall be either a type-specifier or
constexpr."
The actual reason for a failure here is that the semantics of the
range-for loop needs to be corrected to further support constexpr.
Note that
auto && __range = range-init;
is not marked as constexpr, so the following usage of constexpr in the
loop is invalid. Fixing this will be a bit tricky, though.
- Daniel
--
---
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: Alex B <devalexb@gmail.com>
Date: Thu, 3 Oct 2013 07:31:18 -0700 (PDT)
Raw View
------=_Part_243_14945904.1380810678711
Content-Type: text/plain; charset=ISO-8859-1
Interesting.
Sounds like something that could be called "static for" ...
Combine this with a restricted "static if" (see this thread: *
https://groups.google.com/a/isocpp.org/forum/#!searchin/std-proposals/imperative/std-proposals/bX96720ccmU/_lAHMoLI224J
*<https://groups.google.com/a/isocpp.org/forum/#!searchin/std-proposals/imperative/std-proposals/bX96720ccmU/_lAHMoLI224J>)
and template programming suddenly becomes quite similar to regular
programming...
On Thursday, October 3, 2013 10:09:21 AM UTC-4, Andrew Tomazos wrote:
> The following is ill-formed:
>
> template<int x> void f() {}
>
> int main()
> {
> for (constexpr int x : {1,2,3})
> f<x>();
> }
>
> as constexpr cannot specify a loop variable.
>
> Maybe we could say:
>
> for (constexpr T t : L)
>
> is well-formed iff:
>
> constexpr T[] arr = L
>
> is well-formed. The semantics are as if the loop is unrolled in the
> obvious way.
>
> So for the original example it is as if:
>
> int main()
> {
> {
> constexpr int x = 1;
> f<x>();
> }
> {
> constexpr int x = 2;
> f<x>();
> }
> {
> constexpr int x = 3;
> f<x>();
> }
> }
>
>
--
---
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_243_14945904.1380810678711
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr"><div>Interesting.</div><div>Sounds like something that cou=
ld be called "static for" ...</div><div>Combine this with a restricted "sta=
tic if" (see this thread: <a href=3D"https://groups.google.com/a/isocpp.org=
/forum/#!searchin/std-proposals/imperative/std-proposals/bX96720ccmU/_lAHMo=
LI224J"><u><font color=3D"#0066cc">https://groups.google.com/a/isocpp.org/f=
orum/#!searchin/std-proposals/imperative/std-proposals/bX96720ccmU/_lAHMoLI=
224J</font></u></a>) and template programming suddenly becomes quite s=
imilar to regular programming...</div><div><br>On Thursday, October 3,=
2013 10:09:21 AM UTC-4, Andrew Tomazos wrote:</div><blockquote style=3D"ma=
rgin: 0px 0px 0px 0.8ex; padding-left: 1ex; border-left-color: rgb(204, 204=
, 204); border-left-width: 1px; border-left-style: solid;" class=3D"gmail_q=
uote"><div dir=3D"ltr">The following is ill-formed:<br><br><div style=3D"ma=
rgin-left: 40px;"><span style=3D"font-family: courier new,monospace;">templ=
ate<int x> void f() {}</span><br><span style=3D"font-family: courier =
new,monospace;"></span><br><span style=3D"font-family: courier new,monospac=
e;">int main()</span><br><span style=3D"font-family: courier new,monospace;=
">{</span><br><span style=3D"font-family: courier new,monospace;"> &nb=
sp; for (constexpr int x : {1,2,3})</span><br><span style=3D"font-fam=
ily: courier new,monospace;"> f<x&g=
t;();</span><br><span style=3D"font-family: courier new,monospace;">}</span=
><br><span style=3D"font-family: courier new,monospace;"></span></div><span=
style=3D"font-family: courier new,monospace;"><br></span>as <span style=3D=
"font-family: courier new,monospace;">constexpr</span> cannot specify a loo=
p variable.<br><br>Maybe we could say:<br><br><div style=3D"margin-left: 40=
px;"><span style=3D"font-family: courier new,monospace;">for (constexpr T t=
: L)<br></span></div><br>is well-formed iff:<br><br><div style=3D"margin-l=
eft: 40px;"><span style=3D"font-family: courier new,monospace;">constexpr T=
[] arr =3D L</span><br><span style=3D"font-family: courier new,monospace;">=
</span></div><br>is well-formed. The semantics are as if the loop is =
unrolled in the obvious way.<br><br>So for the original example it is as if=
:<br><span style=3D"font-family: courier new,monospace;"><br></span><span s=
tyle=3D"font-family: courier new,monospace;"> int main()<=
/span><br><span style=3D"font-family: courier new,monospace;"></span><span =
style=3D"font-family: courier new,monospace;"> {<br></spa=
n><span style=3D"font-family: courier new,monospace;"> &nb=
sp; {<br> =
constexpr int x =3D 1;<br> =
f<x>();<br> &nb=
sp; }</span><br><span style=3D"font-family: courier new,m=
onospace;"> {<br> &nbs=
p; constexpr int x =3D 2;<b=
r> f<x=
>();<br> }</span><br><span sty=
le=3D"font-family: courier new,monospace;"> &n=
bsp; {<br>  =
; constexpr int x =3D 3;<br>  =
; f<x>();<br> &n=
bsp; }</span><br><span style=3D"font-family: courier new,monospace;">=
}<br><br></span></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 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_243_14945904.1380810678711--
.
Author: inkwizytoryankes@gmail.com
Date: Thu, 3 Oct 2013 09:40:50 -0700 (PDT)
Raw View
------=_Part_5216_28701874.1380818450387
Content-Type: text/plain; charset=ISO-8859-1
I recently suggest similar thing but focused on variadic templates where it
would be more useful:
template<typename... T>
void func()
{
for...(Ti : T) //"loop" through type pack
{
/*code there*/
}
}
`for...` is analogy to `sizeof...`.
Another important thing it need to ignore `break` and `continue`. This is
require to allow integrate with normal loops or switch statement:
switch(i)
{
for...(Ti : T)
{
case Ti::value:
Ti::f();
break; //break for `switch` not `for...`
}
}
Another thing, `for...(` is shorter than `static for(` or `for(constexpr`.
On Thursday, October 3, 2013 4:09:21 PM UTC+2, Andrew Tomazos wrote:
>
> The following is ill-formed:
>
> template<int x> void f() {}
>
> int main()
> {
> for (constexpr int x : {1,2,3})
> f<x>();
> }
>
> as constexpr cannot specify a loop variable.
>
> Maybe we could say:
>
> for (constexpr T t : L)
>
> is well-formed iff:
>
> constexpr T[] arr = L
>
> is well-formed. The semantics are as if the loop is unrolled in the
> obvious way.
>
> So for the original example it is as if:
>
> int main()
> {
> {
> constexpr int x = 1;
> f<x>();
> }
> {
> constexpr int x = 2;
> f<x>();
> }
> {
> constexpr int x = 3;
> f<x>();
> }
> }
>
>
--
---
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_5216_28701874.1380818450387
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr">I recently suggest similar thing but focused on variadic t=
emplates where it would be more useful:<br><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"><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"styled-by-prettify">typename</span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">...</span><span style=3D"color: #000;" class=3D"sty=
led-by-prettify"> T</span><span style=3D"color: #660;" class=3D"styled-by-p=
rettify">></span><span style=3D"color: #000;" class=3D"styled-by-prettif=
y"><br></span><span style=3D"color: #008;" class=3D"styled-by-prettify">voi=
d</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> func</sp=
an><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><span style=
=3D"color: #008;" class=3D"styled-by-prettify">for</span><span style=3D"col=
or: #660;" class=3D"styled-by-prettify">...(</span><span style=3D"color: #6=
06;" class=3D"styled-by-prettify">Ti</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"> 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">//"loop" through t=
ype pack</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><b=
r> </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: #800;" class=3D"s=
tyled-by-prettify">/*code there*/</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><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></div></code></div>`for...` is analogy to `sizeof...`.<=
br>Another important thing it need to ignore `break` and `continue`. This i=
s require to allow integrate with normal loops or switch statement:<br><div=
class=3D"prettyprint" style=3D"background-color: rgb(250, 250, 250); borde=
r-color: rgb(187, 187, 187); border-style: solid; border-width: 1px; word-w=
rap: break-word;"><code class=3D"prettyprint"><div class=3D"subprettyprint"=
><span style=3D"color: #008;" class=3D"styled-by-prettify">switch</span><sp=
an 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 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"styled-by-prettify">for</span><span style=3D"color: #660;" class=3D"sty=
led-by-prettify">...(</span><span style=3D"color: #606;" class=3D"styled-by=
-prettify">Ti</span><span style=3D"color: #000;" class=3D"styled-by-prettif=
y"> </span><span style=3D"color: #660;" class=3D"styled-by-prettify">:</spa=
n><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 s=
tyle=3D"color: #660;" class=3D"styled-by-prettify">{</span><span style=3D"c=
olor: #000;" class=3D"styled-by-prettify"><br> </span><span st=
yle=3D"color: #008;" class=3D"styled-by-prettify">case</span><span style=3D=
"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #=
606;" class=3D"styled-by-prettify">Ti</span><span style=3D"color: #660;" cl=
ass=3D"styled-by-prettify">::</span><span style=3D"color: #000;" class=3D"s=
tyled-by-prettify">value</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: #606;" cl=
ass=3D"styled-by-prettify">Ti</span><span style=3D"color: #660;" class=3D"s=
tyled-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"><br>&=
nbsp; </span><span style=3D"color: #008;" class=3D"sty=
led-by-prettify">break</span><span style=3D"color: #660;" class=3D"styled-b=
y-prettify">;</span><span style=3D"color: #000;" class=3D"styled-by-prettif=
y"> </span><span style=3D"color: #800;" class=3D"styled-by-prettify">//brea=
k for `switch` not `for...`</span><span style=3D"color: #000;" class=3D"sty=
led-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: #660;" class=3D"styled-by-=
prettify">}</span><span style=3D"color: #000;" class=3D"styled-by-prettify"=
><br><br></span></div></code></div>Another thing, `for...(` is shorter than=
`static for(` or `for(<span style=3D"font-family:courier new,monospace">co=
nstexpr</span>`.<br><br><br><br>On Thursday, October 3, 2013 4:09:21 PM UTC=
+2, Andrew Tomazos wrote:<blockquote class=3D"gmail_quote" style=3D"margin:=
0;margin-left: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;"><div =
dir=3D"ltr">The following is ill-formed:<br><br><div style=3D"margin-left:4=
0px"><span style=3D"font-family:courier new,monospace">template<int x>=
; void f() {}</span><br><span style=3D"font-family:courier new,monospace"><=
/span><br><span style=3D"font-family:courier new,monospace">int main()</spa=
n><br><span style=3D"font-family:courier new,monospace">{</span><br><span s=
tyle=3D"font-family:courier new,monospace"> for (constexp=
r int x : {1,2,3})</span><br><span style=3D"font-family:courier new,monospa=
ce"> f<x>();</span><br><span sty=
le=3D"font-family:courier new,monospace">}</span><br><span style=3D"font-fa=
mily:courier new,monospace"></span></div><span style=3D"font-family:courier=
new,monospace"><br></span>as <span style=3D"font-family:courier new,monosp=
ace">constexpr</span> cannot specify a loop variable.<br><br>Maybe we could=
say:<br><br><div style=3D"margin-left:40px"><span style=3D"font-family:cou=
rier new,monospace">for (constexpr T t : L)<br></span></div><br>is well-for=
med iff:<br><br><div style=3D"margin-left:40px"><span style=3D"font-family:=
courier new,monospace">constexpr T[] arr =3D L</span><br><span style=3D"fon=
t-family:courier new,monospace"></span></div><br>is well-formed. The =
semantics are as if the loop is unrolled in the obvious way.<br><br>So for =
the original example it is as if:<br><span style=3D"font-family:courier new=
,monospace"><br></span><span style=3D"font-family:courier new,monospace">&n=
bsp; int main()</span><br><span style=3D"font-family:courier ne=
w,monospace"></span><span style=3D"font-family:courier new,monospace"> =
; {<br></span><span style=3D"font-family:courier new,monospace"=
> {<br> &n=
bsp; constexpr int x =3D 1;<br> &n=
bsp; f<x>();<br=
> }</span><br><span style=3D"font=
-family:courier new,monospace"> {=
<br> cons=
texpr int x =3D 2;<br>  =
; f<x>();<br> }=
</span><br><span style=3D"font-family:courier new,monospace"> &n=
bsp; {<br>  =
; constexpr int x =3D 3;<br>  =
; f<x>();<br> &n=
bsp; }</span><br><span style=3D"font-family:courier=
new,monospace"> }<br><br></span></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 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_5216_28701874.1380818450387--
.
Author: Andrew Tomazos <andrewtomazos@gmail.com>
Date: Thu, 3 Oct 2013 09:41:47 -0700 (PDT)
Raw View
------=_Part_46_18048532.1380818507304
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
On Thursday, October 3, 2013 4:22:48 PM UTC+2, Daniel Kr=FCgler wrote:
>
> 2013/10/3 Andrew Tomazos <andrew...@gmail.com <javascript:>>:=20
> > The following is ill-formed:=20
> >=20
> > template<int x> void f() {}=20
> >=20
> > int main()=20
> > {=20
> > for (constexpr int x : {1,2,3})=20
> > f<x>();=20
> > }=20
> >=20
> > as constexpr cannot specify a loop variable.=20
>
> This is not true, see [stmt.ranged] p2:=20
>
> "In the decl-specifier-seq of a for-range-declaration, each=20
> decl-specifier shall be either a type-specifier or=20
> constexpr."=20
>
> The actual reason for a failure here is that the semantics of the=20
> range-for loop needs to be corrected to further support constexpr.=20
> Note that=20
>
> auto && __range =3D range-init;=20
>
> is not marked as constexpr, so the following usage of constexpr in the=20
> loop is invalid. Fixing this will be a bit tricky, though.=20
>
>
Yes, correct, that is what I meant We could add a constraint on 6.5.4=20
[stmt.ranged] "The range-based for statement", that states the=20
for-range-declaration must not be constexpr, and then define:
6.5.5 The unrolled for statement [stmt.unrolled]
For a for statement of the form
for ( for-range-declaration : expression ) statement
where the for-range-declaration has a constexpr specifier, the statement is=
=20
known as an *unrolled for statement*
let range-init, and begin-expr be defined the same as a range-based for=20
statement
An unrolled for statement is equivalent to:
{
constexpr decltype(*begin-expr) __range[] =3D range-init;
constexpr std::size_t __extent =3D=20
std::extent<decltype(__range)>::value;
{
for-range-declaration =3D __range[0];
statement
}
{
for-range-declaration =3D __range[1];
statement
}
{
for-range-declaration =3D __range[2];
statement
}
/* ... */
{
for-range-declaration =3D __range[__extent-1];
statement
}
}
Where __range and __extent are variables for exposition only.
--=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_46_18048532.1380818507304
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr">On Thursday, October 3, 2013 4:22:48 PM UTC+2, Daniel Kr=
=FCgler wrote:<blockquote class=3D"gmail_quote" style=3D"margin: 0;margin-l=
eft: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;">2013/10/3 Andrew=
Tomazos <<a href=3D"javascript:" target=3D"_blank" gdf-obfuscated-mailt=
o=3D"zwzdU1UtVj4J">andrew...@gmail.com</a>>:
<br>> The following is ill-formed:
<br>>
<br>> template<int x> void f() {}
<br>>
<br>> int main()
<br>> {
<br>> for (constexpr int x : {1,2,3})
<br>> f<x>();
<br>> }
<br>>
<br>> as constexpr cannot specify a loop variable.
<br>
<br>This is not true, see [stmt.ranged] p2:
<br>
<br>"In the decl-specifier-seq of a for-range-declaration, each
<br>decl-specifier shall be either a type-specifier or
<br>constexpr."
<br>
<br>The actual reason for a failure here is that the semantics of the
<br>range-for loop needs to be corrected to further support constexpr.
<br>Note that
<br>
<br>auto && __range =3D range-init;
<br>
<br>is not marked as constexpr, so the following usage of constexpr in the
<br>loop is invalid. Fixing this will be a bit tricky, though.
<br>
<br></blockquote><div><br>Yes, correct, that is what I meant We could=
add a constraint on 6.5.4 [stmt.ranged] "The range-based for statement", t=
hat states the for-range-declaration must not be constexpr, and then define=
:<br><br>6.5.5 The unrolled <span style=3D"font-family: courier new,monospa=
ce;">for</span> statement [stmt.unrolled]<br><br>For a for statement of the=
form<br><br> for ( for-range-declaration : expression ) =
statement<br><br>where the for-range-declaration has a constexpr specifier,=
the statement is known as an <i><span style=3D"font-family: arial,sans-ser=
if;">unrolled for statement</span></i><br><br>let range-init, and begin-exp=
r be defined the same as a range-based for statement<br><br>An unrolled for=
statement is equivalent to:<br><br> {<br> &nb=
sp; constexpr decltype(*begin-expr) __range[] =3D r=
ange-init;<br> constexpr std::siz=
e_t __extent =3D std::extent<decltype(__range)>::value;<br> &nbs=
p; {<br> &=
nbsp; for-range-declaration =3D __range[0];<b=
r> =
statement<br> }<br> &n=
bsp; {<br>  =
; for-range-declaration =3D __range[1];<br>&n=
bsp; stat=
ement<br> }<br> =
{<br> &nb=
sp; for-range-declaration =3D __range[2];<br> =
statemen=
t<br> }<br> &nbs=
p; /* ... */<br>  =
; {<br> &n=
bsp; for-range-declaration =3D __range[__extent-1];<br> &n=
bsp; statement<br>&nb=
sp; }<br> }<br><br>Wh=
ere __range and __extent are variables for exposition only.<br><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 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_46_18048532.1380818507304--
.
Author: Alex B <devalexb@gmail.com>
Date: Thu, 3 Oct 2013 13:44:32 -0400
Raw View
--089e0118293a09416704e7d9bd41
Content-Type: text/plain; charset=ISO-8859-1
On Thu, Oct 3, 2013 at 12:40 PM, <inkwizytoryankes@gmail.com> wrote:
> I recently suggest similar thing but focused on variadic templates where
> it would be more useful:
> template<typename... T>
> void func()
> {
> for...(Ti : T) //"loop" through type pack
> {
> /*code there*/
> }
> }
> `for...` is analogy to `sizeof...`.
> Another important thing it need to ignore `break` and `continue`. This is
> require to allow integrate with normal loops or switch statement:
> switch(i)
> {
> for...(Ti : T)
> {
> case Ti::value:
> Ti::f();
> break; //break for `switch` not `for...`
> }
> }
>
> Another thing, `for...(` is shorter than `static for(` or `for(constexpr`.
>
>
Interesting as well. The downside about your solution is that it requires a
pack. So for example, if I want to call a funcion f over all the elements
of a tuple-like class (that could be tuple, array or pair), I will need to
dispatch to an extra function taking an index_sequence:
template <class TupleLike, std::size_t... Seq>
void _func_impl(TupleLike&& t, std::index_sequence<Seq...>)
{
for... (I : Seq)
f(std::get<I>(std::forward<TupleLike>(t)));
}
template <class TupleLike>
void func(TupleLike&& t)
{
_func_impl(
std::forward<TupleLike>(t),
std::make_index_sequence<std::tuple_size<std::remove_reference_t<TupleLike>>::value
>{}
);
}
However that might not be a burden in the future if there is a way to
"generate a pack" and/or overload operator... (see this very interesting
thread:
https://groups.google.com/a/isocpp.org/forum/#!starred/std-proposals/g1HziHt1lbo
).
template <class TupleLike>
void func(TupleLike&& t)
{
for... (v : std::forward<TupleLike>(t))
f(v);
}
--
---
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/.
--089e0118293a09416704e7d9bd41
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr"><br><div class=3D"gmail_extra"><div class=3D"gmail_quote">=
On Thu, Oct 3, 2013 at 12:40 PM, <span dir=3D"ltr"><<a href=3D"mailto:i=
nkwizytoryankes@gmail.com" target=3D"_blank">inkwizytoryankes@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 recently suggest similar thing but focu=
sed on variadic templates where it would be more useful:<br>
<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:rgb(0,0,136)">=
template</span><span style=3D"color:rgb(102,102,0)"><</span><span style=
=3D"color:rgb(0,0,136)">typename</span><span style=3D"color:rgb(102,102,0)"=
>...</span><span style> T</span><span style=3D"color:rgb(102,102,0)">></=
span><span style><br>
</span><span style=3D"color:rgb(0,0,136)">void</span><span style> func</spa=
n><span style=3D"color:rgb(102,102,0)">()</span><span style><br></span><spa=
n style=3D"color:rgb(102,102,0)">{</span><span style><br>=A0 =A0 </span><sp=
an style=3D"color:rgb(0,0,136)">for</span><span style=3D"color:rgb(102,102,=
0)">...(</span><span style=3D"color:rgb(102,0,102)">Ti</span><span style> <=
/span><span style=3D"color:rgb(102,102,0)">:</span><span style> T</span><sp=
an style=3D"color:rgb(102,102,0)">)</span><span style> </span><span style=
=3D"color:rgb(136,0,0)">//"loop" through type pack</span><span st=
yle><br>
=A0 =A0 </span><span style=3D"color:rgb(102,102,0)">{</span><span style><br=
>=A0 =A0 =A0 =A0 </span><span style=3D"color:rgb(136,0,0)">/*code there*/</=
span><span style><br>=A0 =A0 </span><span style=3D"color:rgb(102,102,0)">}<=
/span><span style><br>
</span><span style=3D"color:rgb(102,102,0)">}</span><span style><br></span>=
</div></code></div>`for...` is analogy to `sizeof...`.<br>Another important=
thing it need to ignore `break` and `continue`. This is require to allow i=
ntegrate with normal loops or switch statement:<br>
<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:rgb(0,0,136)">=
switch</span><span style=3D"color:rgb(102,102,0)">(</span><span style>i</sp=
an><span style=3D"color:rgb(102,102,0)">)</span><span style><br>
</span><span style=3D"color:rgb(102,102,0)">{</span><span style><br>=A0 =A0=
</span><span style=3D"color:rgb(0,0,136)">for</span><span style=3D"color:r=
gb(102,102,0)">...(</span><span style=3D"color:rgb(102,0,102)">Ti</span><sp=
an style> </span><span style=3D"color:rgb(102,102,0)">:</span><span style> =
T</span><span style=3D"color:rgb(102,102,0)">)</span><span style><br>
=A0 =A0 </span><span style=3D"color:rgb(102,102,0)">{</span><span style><br=
>=A0 =A0 </span><span style=3D"color:rgb(0,0,136)">case</span><span style> =
</span><span style=3D"color:rgb(102,0,102)">Ti</span><span style=3D"color:r=
gb(102,102,0)">::</span><span style>value</span><span style=3D"color:rgb(10=
2,102,0)">:</span><span style><br>
=A0 =A0 =A0 =A0 </span><span style=3D"color:rgb(102,0,102)">Ti</span><span =
style=3D"color:rgb(102,102,0)">::</span><span style>f</span><span style=3D"=
color:rgb(102,102,0)">();</span><span style><br>=A0 =A0 =A0 =A0 </span><spa=
n style=3D"color:rgb(0,0,136)">break</span><span style=3D"color:rgb(102,102=
,0)">;</span><span style> </span><span style=3D"color:rgb(136,0,0)">//break=
for `switch` not `for...`</span><span style><br>
=A0 =A0 </span><span style=3D"color:rgb(102,102,0)">}</span><span style><br=
></span><span style=3D"color:rgb(102,102,0)">}</span><span style><br><br></=
span></div></code></div>Another thing, `for...(` is shorter than `static fo=
r(` or `for(<span style=3D"font-family:'courier new',monospace">con=
stexpr</span>`.<div>
<div class=3D"h5"><br></div></div></div></blockquote><div>=A0</div><div>Int=
eresting as well. The downside about your solution is that it requires a pa=
ck. So for example, if I want to call a funcion f over all the elements of =
a tuple-like class (that could be tuple, array or pair), I will need to dis=
patch to an extra function taking an index_sequence:</div>
<div><br></div><div><div><font face=3D"courier new, monospace">template <=
;class TupleLike, std::size_t... Seq></font></div><div><font face=3D"cou=
rier new, monospace">void _func_impl(TupleLike&& t, std::index_sequ=
ence<Seq...>)</font></div>
<div><font face=3D"courier new, monospace">{</font></div><div><font face=3D=
"courier new, monospace">=A0 =A0for... (I : Seq)</font></div><div><font fac=
e=3D"courier new, monospace">=A0 =A0 =A0 f(std::get<I>(std::forward&l=
t;TupleLike>(t)));</font></div>
<div><font face=3D"courier new, monospace">}</font></div></div><div><font f=
ace=3D"courier new, monospace"><br></font></div><div><div><font face=3D"cou=
rier new, monospace">template <class TupleLike></font></div><div><fon=
t face=3D"courier new, monospace">void func(TupleLike&& t)</font></=
div>
<div><font face=3D"courier new, monospace">{</font></div><div><font face=3D=
"courier new, monospace">=A0 =A0_func_impl(</font></div><div><font face=3D"=
courier new, monospace">=A0 =A0 =A0 std::forward<TupleLike>(t),</font=
></div><div>
<font face=3D"courier new, monospace">=A0 =A0 =A0 std::make_index_sequence&=
lt;std::tuple_size<std::remove_reference_t<TupleLike>>::value &=
gt;{}</font></div><div><font face=3D"courier new, monospace">=A0 =A0);</fon=
t></div><div>
<font face=3D"courier new, monospace">}</font></div></div><div><br></div><d=
iv><br></div><div>However that might not be a burden in the future if there=
is a way to "generate a pack" and/or overload operator... (see t=
his very interesting thread:=A0<a href=3D"https://groups.google.com/a/isocp=
p.org/forum/#!starred/std-proposals/g1HziHt1lbo">https://groups.google.com/=
a/isocpp.org/forum/#!starred/std-proposals/g1HziHt1lbo</a>).</div>
<div><br></div><div><font face=3D"courier new, monospace">template <clas=
s TupleLike></font></div><div><font face=3D"courier new, monospace">void=
func(TupleLike&& t)</font></div><div><font face=3D"courier new, mo=
nospace">{</font></div>
<div><font face=3D"courier new, monospace">=A0 =A0for... (v : std::forward&=
lt;TupleLike>(t))</font></div><div><font face=3D"courier new, monospace"=
>=A0 =A0 =A0 f(v);</font></div><div><font face=3D"courier new, monospace">}=
</font></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 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 />
--089e0118293a09416704e7d9bd41--
.
Author: Andrew Tomazos <andrewtomazos@gmail.com>
Date: Thu, 3 Oct 2013 11:38:12 -0700 (PDT)
Raw View
------=_Part_91_22557899.1380825492962
Content-Type: text/plain; charset=ISO-8859-1
On Thursday, October 3, 2013 6:40:50 PM UTC+2, inkwizyt...@gmail.com wrote:
>
> I recently suggest similar thing but focused on variadic templates where
> it would be more useful:
> template<typename... T>
> void func()
> {
> for...(Ti : T) //"loop" through type pack
> {
> /*code there*/
> }
> }
>
For non-type template parameter packs unrolled for statements work just
fine:
template<int... X>
void func()
{
for (constexpr auto x : {X...})
g<x>();
}
For type template parameter packs it doesn't currently work yet, this is a
good thought. I would suggest extending unrolled for statements to allow
the typedef specifier and a type-init-list (a braced-init-list of type-ids):
template<typename... Args>
void func()
{
for (typedef T : {Args...})
g<T>();
}
The semantics are clear. The declaration at the start of each block
becomes a typedef of the corresponding type.
Another important thing it need to ignore `break` and `continue`.
>
I think break and continue should have their usual expected semantics.
break jumps to the end of the last unrolled block. continue jumps to the
start of the next one.
> This is require to allow integrate with normal loops or switch statement:
> switch(i)
> {
> for...(Ti : T)
> {
> case Ti::value:
> Ti::f();
> break; //break for `switch` not `for...`
> }
> }
>
>
That's not necessary. You can do what you want as follows:
for (typedef Ti : {T...})
if (i == Ti::value)
{
Ti::f();
break;
}
The optimizer will notice the pattern and then generate code as fast as a
switch statement.
> Another thing, `for...(` is shorter than `static for(` or `for(constexpr`.
>
I think that using the constexpr and typedef specifiers are better choices,
given that they already have exactly the right semantic meaning.
--
---
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_91_22557899.1380825492962
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr">On Thursday, October 3, 2013 6:40:50 PM UTC+2, inkwizyt...=
@gmail.com wrote:<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 recently suggest similar thing but focused on variadic templates wher=
e it would be more useful:<br><div style=3D"background-color:rgb(250,250,25=
0);border-color:rgb(187,187,187);border-style:solid;border-width:1px;word-w=
rap:break-word"><code><div><span style=3D"color:#008">template</span><span =
style=3D"color:#660"><</span><span style=3D"color:#008">typename</span><=
span style=3D"color:#660">...</span><span style=3D"color:#000"> T</span><sp=
an style=3D"color:#660">></span><span style=3D"color:#000"><br></span><s=
pan style=3D"color:#008">void</span><span style=3D"color:#000"> func</span>=
<span style=3D"color:#660">()</span><span style=3D"color:#000"><br></span><=
span style=3D"color:#660">{</span><span style=3D"color:#000"><br> &nb=
sp; </span><span style=3D"color:#008">for</span><span style=3D"color:#660">=
....(</span><span style=3D"color:#606">Ti</span><span style=3D"color:#000"> =
</span><span style=3D"color:#660">:</span><span style=3D"color:#000"> T</sp=
an><span style=3D"color:#660">)</span><span style=3D"color:#000"> </span><s=
pan style=3D"color:#800">//"loop" through type pack</span><span style=3D"co=
lor:#000"><br> </span><span style=3D"color:#660">{</span><span=
style=3D"color:#000"><br> </span><span style=3D=
"color:#800">/*code there*/</span><span style=3D"color:#000"><br> &nb=
sp; </span><span style=3D"color:#660">}</span><span style=3D"color:#000"><b=
r></span><span style=3D"color:#660">}</span><span style=3D"color:#000"><br>=
</span></div></code></div></div></blockquote><div><br>For non-type template=
parameter packs unrolled for statements work just fine:<br><br>  =
; template<int... X><br> void func()<br> =
; {<br> for (constexp=
r auto x : {X...})<br>  =
; g<x>();<br> }<br><br>For type templat=
e parameter packs it doesn't currently work yet, this is a good thought.&nb=
sp; I would suggest extending unrolled for statements to allow the <span st=
yle=3D"font-family: courier new,monospace;">typedef</span> specifier and a =
type-init-list (a braced-init-list of type-ids):<br><br> =
template<typename... Args><br> void func()<br> =
; {<br> for (typedef =
T : {Args...})<br> &nb=
sp; g<T>();<br> }<br><br>The semantics are cl=
ear. The declaration at the start of each block becomes a typedef of =
the corresponding type.<br><br></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">Another important thing it need to ignore `break` a=
nd `continue`.<br></div></blockquote><div><br>I think <span style=3D"font-f=
amily: courier new,monospace;">break</span> and <span style=3D"font-family:=
courier new,monospace;">continue</span> should have their usual expected s=
emantics. <span style=3D"font-family: courier new,monospace;">break</=
span> jumps to the end of the last unrolled block. <span style=3D"fon=
t-family: courier new,monospace;">continue</span> jumps to the start of the=
next one.<br> <br>> This is require to allow integrate with norma=
l loops or switch statement:</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 style=3D"background-color:rgb(250,250,250);bord=
er-color:rgb(187,187,187);border-style:solid;border-width:1px;word-wrap:bre=
ak-word"><code><div><span style=3D"color:#008">switch</span><span style=3D"=
color:#660">(</span><span style=3D"color:#000">i</span><span style=3D"color=
:#660">)</span><span style=3D"color:#000"><br></span><span style=3D"color:#=
660">{</span><span style=3D"color:#000"><br> </span><span styl=
e=3D"color:#008">for</span><span style=3D"color:#660">...(</span><span styl=
e=3D"color:#606">Ti</span><span style=3D"color:#000"> </span><span style=3D=
"color:#660">:</span><span style=3D"color:#000"> T</span><span style=3D"col=
or:#660">)</span><span style=3D"color:#000"><br> </span><span =
style=3D"color:#660">{</span><span style=3D"color:#000"><br> <=
/span><span style=3D"color:#008">case</span><span style=3D"color:#000"> </s=
pan><span style=3D"color:#606">Ti</span><span style=3D"color:#660">::</span=
><span style=3D"color:#000">value</span><span style=3D"color:#660">:</span>=
<span style=3D"color:#000"><br> </span><span sty=
le=3D"color:#606">Ti</span><span style=3D"color:#660">::</span><span style=
=3D"color:#000">f</span><span style=3D"color:#660">();</span><span style=3D=
"color:#000"><br> </span><span style=3D"color:#0=
08">break</span><span style=3D"color:#660">;</span><span style=3D"color:#00=
0"> </span><span style=3D"color:#800">//break for `switch` not `for...`</sp=
an><span style=3D"color:#000"><br> </span><span style=3D"color=
:#660">}</span><span style=3D"color:#000"><br></span><span style=3D"color:#=
660">}</span><span style=3D"color:#000"><br><br></span></div></code></div><=
/div></blockquote><div><br>That's not necessary. You can do what you =
want as follows:<br><span style=3D"font-family: courier new,monospace;"><br=
> for (typedef Ti : {T...})<br> &n=
bsp; if (i =3D=3D Ti::value)<br> &=
nbsp; {<br> &nbs=
p; Ti::f();<br> =
break;<br> }<br></sp=
an><br>The optimizer will notice the pattern and then generate code as fast=
as a switch statement.<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;"><div dir=3D"ltr">Another thing, `for...(` is shorter than `static =
for(` or `for(<span style=3D"font-family:courier new,monospace">constexpr</=
span>`.<br></div></blockquote><div dir=3D"ltr"><br>I think that using the <=
span style=3D"font-family: courier new,monospace;">constexpr</span> and <sp=
an style=3D"font-family: courier new,monospace;">typedef</span> specifiers =
are better choices, given that they already have exactly the right semantic=
meaning.<br><br><span style=3D"font-family:courier new,monospace"></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 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_91_22557899.1380825492962--
.
Author: Alex B <devalexb@gmail.com>
Date: Thu, 3 Oct 2013 15:31:02 -0400
Raw View
--089e013d14cae8b54904e7db3942
Content-Type: text/plain; charset=ISO-8859-1
On Thu, Oct 3, 2013 at 2:38 PM, Andrew Tomazos <andrewtomazos@gmail.com>wrote:
> I would suggest extending unrolled for statements to allow the typedefspecifier and a type-init-list (a braced-init-list of type-ids):
>
> template<typename... Args>
> void func()
> {
> for (typedef T : {Args...})
> g<T>();
> }
>
> The semantics are clear. The declaration at the start of each block
> becomes a typedef of the corresponding type.
>
Maybe "using" instead of "typedef"? Usually, what follow typedef is the
name of the original type, not the alias.
*typedef *int *T*;
*using T* = int; // closer to what you want
Also, having a list of types delimited by {} is a bit weird and it might be
complicated to make it work...
> Another important thing it need to ignore `break` and `continue`.
>>
>
> I think break and continue should have their usual expected semantics.
> break jumps to the end of the last unrolled block. continue jumps to the
> start of the next one.
>
>
> > This is require to allow integrate with normal loops or switch statement:
>
>> switch(i)
>> {
>> for...(Ti : T)
>> {
>> case Ti::value:
>> Ti::f();
>> break; //break for `switch` not `for...`
>> }
>> }
>>
>>
>
I think I looked at that sample too quickly; I agree as well that break and
continue should not have special rules. Your "for..." should really behave
like a regular "for" in term of scope as well. That debate is going in the
same direction as the "static if" debate: should it introduce a new scope?
Consensus so far is: definitely.
Of course, that would break the switch example...
--
---
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/.
--089e013d14cae8b54904e7db3942
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr"><br><div class=3D"gmail_extra"><div class=3D"gmail_quote">=
On Thu, Oct 3, 2013 at 2:38 PM, Andrew Tomazos <span dir=3D"ltr"><<a hre=
f=3D"mailto:andrewtomazos@gmail.com" 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"><div class=3D"im"><span sty=
le=3D"color:rgb(34,34,34)">I would suggest extending unrolled for statement=
s to allow the </span><span style=3D"color:rgb(34,34,34);font-family:'c=
ourier new',monospace">typedef</span><span style=3D"color:rgb(34,34,34)=
"> specifier and a type-init-list (a braced-init-list of type-ids):</span><=
br>
</div><div><br>=A0=A0=A0 template<typename... Args><br>=A0=A0=A0 void=
func()<br>=A0=A0=A0 {<br>=A0=A0=A0=A0=A0=A0=A0 for (typedef T : {Args...})=
<br>=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 g<T>();<br>=A0=A0=A0 }<br><br>T=
he semantics are clear.=A0 The declaration at the start of each block becom=
es a typedef of the corresponding type.<br>
</div></div></blockquote><div><br></div><div>Maybe "using" instea=
d of "typedef"? Usually, what follow typedef is the name of the o=
riginal type, not the alias.</div><div><font face=3D"courier new, monospace=
"><b>typedef </b>int <b>T</b>;</font></div>
<div><font face=3D"courier new, monospace"><b>using T</b> =3D int; // close=
r to what you want</font></div><div><br></div><div>Also, having a list of t=
ypes delimited by {} is a bit weird and it might be complicated to make it =
work...</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"><div><br></d=
iv><div class=3D"im"><blockquote class=3D"gmail_quote" style=3D"margin:0;ma=
rgin-left:0.8ex;border-left:1px #ccc solid;padding-left:1ex">
<div dir=3D"ltr">Another important thing it need to ignore `break` and `con=
tinue`.<br></div></blockquote></div><div><br>I think <span style=3D"font-fa=
mily:courier new,monospace">break</span> and <span style=3D"font-family:cou=
rier new,monospace">continue</span> should have their usual expected semant=
ics.=A0 <span style=3D"font-family:courier new,monospace">break</span> jump=
s to the end of the last unrolled block.=A0 <span style=3D"font-family:cour=
ier new,monospace">continue</span> jumps to the start of the next one.<div =
class=3D"im">
<br>=A0<br>> This is require to allow integrate with normal loops or sw=
itch statement:</div></div><div class=3D"im"><blockquote class=3D"gmail_quo=
te" style=3D"margin:0;margin-left:0.8ex;border-left:1px #ccc solid;padding-=
left:1ex">
<div dir=3D"ltr"><div style=3D"background-color:rgb(250,250,250);border-col=
or:rgb(187,187,187);border-style:solid;border-width:1px;word-wrap:break-wor=
d"><code><div><span style=3D"color:#008">switch</span><span style=3D"color:=
#660">(</span><span style>i</span><span style=3D"color:#660">)</span><span =
style><br>
</span><span style=3D"color:#660">{</span><span style><br>=A0 =A0 </span><s=
pan style=3D"color:#008">for</span><span style=3D"color:#660">...(</span><s=
pan style=3D"color:#606">Ti</span><span style> </span><span style=3D"color:=
#660">:</span><span style> T</span><span style=3D"color:#660">)</span><span=
style><br>
=A0 =A0 </span><span style=3D"color:#660">{</span><span style><br>=A0 =A0 <=
/span><span style=3D"color:#008">case</span><span style> </span><span style=
=3D"color:#606">Ti</span><span style=3D"color:#660">::</span><span style>va=
lue</span><span style=3D"color:#660">:</span><span style><br>
=A0 =A0 =A0 =A0 </span><span style=3D"color:#606">Ti</span><span style=3D"c=
olor:#660">::</span><span style>f</span><span style=3D"color:#660">();</spa=
n><span style><br>=A0 =A0 =A0 =A0 </span><span style=3D"color:#008">break</=
span><span style=3D"color:#660">;</span><span style> </span><span style=3D"=
color:#800">//break for `switch` not `for...`</span><span style><br>
=A0 =A0 </span><span style=3D"color:#660">}</span><span style><br></span><s=
pan style=3D"color:#660">}</span><span style><br><br></span></div></code></=
div></div></blockquote></div><div><br></div></div></blockquote><div><br></d=
iv><div>
I think I looked at that sample too quickly; I agree as well that break and=
continue should not have special rules. Your "for..." should rea=
lly behave like a regular "for" in term of scope as well. That de=
bate is going in the same direction as the "static if" debate: sh=
ould it introduce a new scope? Consensus so far is: definitely.</div>
<div><br></div><div>Of course, that would break the switch example...</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 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 />
--089e013d14cae8b54904e7db3942--
.
Author: inkwizytoryankes@gmail.com
Date: Thu, 3 Oct 2013 13:15:30 -0700 (PDT)
Raw View
------=_Part_110_27159961.1380831330914
Content-Type: text/plain; charset=ISO-8859-1
Yes, it should have scope, and will not break switch because switch allow
loops (and scopes) inside: http://en.wikipedia.org/wiki/Duff%27s_device
(and it should work in C++ at least in g++ it still works).
On Thursday, October 3, 2013 9:31:02 PM UTC+2, Alex B wrote:
>
>
> On Thu, Oct 3, 2013 at 2:38 PM, Andrew Tomazos <andrew...@gmail.com<javascript:>
> > wrote:
>
>> I would suggest extending unrolled for statements to allow the typedefspecifier and a type-init-list (a braced-init-list of type-ids):
>>
>> template<typename... Args>
>> void func()
>> {
>> for (typedef T : {Args...})
>> g<T>();
>> }
>>
>> The semantics are clear. The declaration at the start of each block
>> becomes a typedef of the corresponding type.
>>
>
> Maybe "using" instead of "typedef"? Usually, what follow typedef is the
> name of the original type, not the alias.
> *typedef *int *T*;
> *using T* = int; // closer to what you want
>
> Also, having a list of types delimited by {} is a bit weird and it might
> be complicated to make it work...
>
>
>> Another important thing it need to ignore `break` and `continue`.
>>>
>>
>> I think break and continue should have their usual expected semantics.
>> break jumps to the end of the last unrolled block. continue jumps to
>> the start of the next one.
>>
>>
>> > This is require to allow integrate with normal loops or switch
>> statement:
>>
>>> switch(i)
>>> {
>>> for...(Ti : T)
>>> {
>>> case Ti::value:
>>> Ti::f();
>>> break; //break for `switch` not `for...`
>>> }
>>> }
>>>
>>>
>>
> I think I looked at that sample too quickly; I agree as well that break
> and continue should not have special rules. Your "for..." should really
> behave like a regular "for" in term of scope as well. That debate is going
> in the same direction as the "static if" debate: should it introduce a new
> scope? Consensus so far is: definitely.
>
> Of course, that would break the switch example...
>
--
---
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_110_27159961.1380831330914
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr">Yes, it should have scope, and will not break switch becau=
se switch allow loops (and scopes) inside: http://en.wikipedia.org/wiki/Duf=
f%27s_device (and it should work in C++ at least in g++ it still works).<br=
><br><br>On Thursday, October 3, 2013 9:31:02 PM UTC+2, Alex B wrote:<block=
quote class=3D"gmail_quote" style=3D"margin: 0;margin-left: 0.8ex;border-le=
ft: 1px #ccc solid;padding-left: 1ex;"><div dir=3D"ltr"><br><div><div class=
=3D"gmail_quote">On Thu, Oct 3, 2013 at 2:38 PM, Andrew Tomazos <span dir=
=3D"ltr"><<a href=3D"javascript:" target=3D"_blank" gdf-obfuscated-mailt=
o=3D"kTGd-hADsUEJ">andrew...@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"><div><span style=3D"color:r=
gb(34,34,34)">I would suggest extending unrolled for statements to allow th=
e </span><span style=3D"color:rgb(34,34,34);font-family:'courier new',monos=
pace">typedef</span><span style=3D"color:rgb(34,34,34)"> specifier and a ty=
pe-init-list (a braced-init-list of type-ids):</span><br>
</div><div><br> template<typename... Args><br> =
; void func()<br> {<br> &nbs=
p; for (typedef T : {Args...})<br>  =
; g<T>();<br> &n=
bsp; }<br><br>The semantics are clear. The declaration at the start o=
f each block becomes a typedef of the corresponding type.<br>
</div></div></blockquote><div><br></div><div>Maybe "using" instead of "type=
def"? Usually, what follow typedef is the name of the original type, not th=
e alias.</div><div><font face=3D"courier new, monospace"><b>typedef </b>int=
<b>T</b>;</font></div>
<div><font face=3D"courier new, monospace"><b>using T</b> =3D int; // close=
r to what you want</font></div><div><br></div><div>Also, having a list of t=
ypes delimited by {} is a bit weird and it might be complicated to make it =
work...</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"><div><br></d=
iv><div><blockquote class=3D"gmail_quote" style=3D"margin:0;margin-left:0.8=
ex;border-left:1px #ccc solid;padding-left:1ex">
<div dir=3D"ltr">Another important thing it need to ignore `break` and `con=
tinue`.<br></div></blockquote></div><div><br>I think <span style=3D"font-fa=
mily:courier new,monospace">break</span> and <span style=3D"font-family:cou=
rier new,monospace">continue</span> should have their usual expected semant=
ics. <span style=3D"font-family:courier new,monospace">break</span> j=
umps to the end of the last unrolled block. <span style=3D"font-famil=
y:courier new,monospace">continue</span> jumps to the start of the next one=
..<div>
<br> <br>> This is require to allow integrate with normal loops or=
switch statement:</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 style=3D"background-color:rgb(250,250,250);border-col=
or:rgb(187,187,187);border-style:solid;border-width:1px;word-wrap:break-wor=
d"><code><div><span style=3D"color:#008">switch</span><span style=3D"color:=
#660">(</span><span>i</span><span style=3D"color:#660">)</span><span><br>
</span><span style=3D"color:#660">{</span><span><br> </span><s=
pan style=3D"color:#008">for</span><span style=3D"color:#660">...(</span><s=
pan style=3D"color:#606">Ti</span><span> </span><span style=3D"color:#660">=
:</span><span> T</span><span style=3D"color:#660">)</span><span><br>
</span><span style=3D"color:#660">{</span><span><br> &n=
bsp; </span><span style=3D"color:#008">case</span><span> </span><span style=
=3D"color:#606">Ti</span><span style=3D"color:#660">::</span><span>value</s=
pan><span style=3D"color:#660">:</span><span><br>
</span><span style=3D"color:#606">Ti</span><spa=
n style=3D"color:#660">::</span><span>f</span><span style=3D"color:#660">()=
;</span><span><br> </span><span style=3D"color:#=
008">break</span><span style=3D"color:#660">;</span><span> </span><span sty=
le=3D"color:#800">//break for `switch` not `for...`</span><span><br>
</span><span style=3D"color:#660">}</span><span><br></span><s=
pan style=3D"color:#660">}</span><span><br><br></span></div></code></div></=
div></blockquote></div><div><br></div></div></blockquote><div><br></div><di=
v>
I think I looked at that sample too quickly; I agree as well that break and=
continue should not have special rules. Your "for..." should really behave=
like a regular "for" in term of scope as well. That debate is going in the=
same direction as the "static if" debate: should it introduce a new scope?=
Consensus so far is: definitely.</div>
<div><br></div><div>Of course, that would break the switch example...</div>=
</div></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 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_110_27159961.1380831330914--
.
Author: Richard Smith <richard@metafoo.co.uk>
Date: Thu, 3 Oct 2013 13:34:12 -0700
Raw View
--089e016339d8d2739704e7dc1b9a
Content-Type: text/plain; charset=ISO-8859-1
On Thu, Oct 3, 2013 at 7:09 AM, Andrew Tomazos <andrewtomazos@gmail.com>wrote:
> The following is ill-formed:
>
> template<int x> void f() {}
>
> int main()
> {
> for (constexpr int x : {1,2,3})
> f<x>();
> }
>
> as constexpr cannot specify a loop variable.
>
It's not true that we can't use 'constexpr' to specify a loop variable.
Hint:
struct my_iterator {
// ...
constexpr operator int() { return 0; }
// ...
};
(It's not very useful, because the value of the loop variable can't depend
on the range, but it is possible.)
The only reason we allow 'constexpr' in this position is so that the syntax
of range-based and non-range-based for loops are identical up until we hit
the ':'. See DR1204.
Maybe we could say:
>
> for (constexpr T t : L)
>
> is well-formed iff:
>
> constexpr T[] arr = L
>
> is well-formed. The semantics are as if the loop is unrolled in the
> obvious way.
>
This seems like a strange approach to me. If you want to force loop
unrolling, it would seem much more natural to use a pack expansion. Using a
construct like 'for' would violate peoples' intuitions ('for' does not
usually imply code duplication, and a 'constexpr' variable declaration can
usually have only a single value).
In discussions with members of the reflection SG, a syntax like:
f<...{1, 2, 3}>() ...;
was discussed and had some support (here, ...{1, 2, 3} is a pack literal,
and ...; indicates a statement pack expansion).
So for the original example it is as if:
>
> int main()
> {
> {
> constexpr int x = 1;
> f<x>();
> }
> {
> constexpr int x = 2;
> f<x>();
> }
> {
> constexpr int x = 3;
> f<x>();
> }
> }
>
> --
>
> ---
> 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/.
--089e016339d8d2739704e7dc1b9a
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr">On Thu, Oct 3, 2013 at 7:09 AM, Andrew Tomazos <span dir=
=3D"ltr"><<a href=3D"mailto:andrewtomazos@gmail.com" target=3D"_blank">a=
ndrewtomazos@gmail.com</a>></span> wrote:<br><div class=3D"gmail_extra">=
<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 dir=3D"ltr">The following is ill-formed=
:<br><br><div style=3D"margin-left:40px"><span style=3D"font-family:courier=
new,monospace">template<int x> void f() {}</span><br>
<span style=3D"font-family:courier new,monospace"></span><br><span style=3D=
"font-family:courier new,monospace">int main()</span><br><span style=3D"fon=
t-family:courier new,monospace">{</span><br><span style=3D"font-family:cour=
ier new,monospace">=A0=A0=A0 for (constexpr int x : {1,2,3})</span><br>
<span style=3D"font-family:courier new,monospace">=A0=A0=A0 =A0=A0=A0 f<=
x>();</span><br><span style=3D"font-family:courier new,monospace">}</spa=
n><br><span style=3D"font-family:courier new,monospace"></span></div><span =
style=3D"font-family:courier new,monospace"><br>
</span>as <span style=3D"font-family:courier new,monospace">constexpr</span=
> cannot specify a loop variable.<br></div></blockquote><div><br></div><div=
>It's not true that we can't use 'constexpr' to specify a l=
oop variable. Hint:</div>
<div><br></div><div>struct my_iterator {</div><div>=A0 // ...</div><div>=A0=
constexpr operator int() { return 0; }</div><div>=A0 // ...</div><div>};</=
div><div><br></div><div>(It's not very useful, because the value of the=
loop variable can't depend on the range, but it is possible.)</div>
<div><br></div><div>The only reason we allow 'constexpr' in this po=
sition is so that the syntax of range-based and non-range-based for loops a=
re identical up until we hit the ':'. See DR1204.</div><div><br>
</div><blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-l=
eft:1px #ccc solid;padding-left:1ex"><div dir=3D"ltr">Maybe we could say:<b=
r><br><div style=3D"margin-left:40px"><span style=3D"font-family:courier ne=
w,monospace">for (constexpr T t : L)<br>
</span></div><br>is well-formed iff:<br><br><div style=3D"margin-left:40px"=
><span style=3D"font-family:courier new,monospace">constexpr T[] arr =3D L<=
/span><br><span style=3D"font-family:courier new,monospace"></span></div><b=
r>is well-formed.=A0 The semantics are as if the loop is unrolled in the ob=
vious way.<br>
</div></blockquote><div><br></div><div>This seems like a strange approach t=
o me. If you want to force loop unrolling, it would seem much more natural =
to use a pack expansion. Using a construct like 'for' would violate=
peoples' intuitions ('for' does not usually imply code duplica=
tion, and a 'constexpr' variable declaration can usually have only =
a single value).</div>
<div><br></div><div>In discussions with members of the reflection SG, a syn=
tax like:</div><div><br></div><div>f<...{1, 2, 3}>() ...;</div><div><=
br></div><div>was discussed and had some support (here, ...{1, 2, 3} is a p=
ack literal, and ...; indicates a statement pack expansion).</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">So for the o=
riginal example it is as if:<br><span style=3D"font-family:courier new,mono=
space"><br>
</span><span style=3D"font-family:courier new,monospace">=A0=A0=A0 int main=
()</span><br><span style=3D"font-family:courier new,monospace"></span><span=
style=3D"font-family:courier new,monospace">=A0=A0=A0 {<br></span><span st=
yle=3D"font-family:courier new,monospace">=A0=A0=A0=A0=A0=A0=A0 {<br>
=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 constexpr int x =3D 1;<br>=A0=A0=A0=A0=A0=
=A0=A0=A0=A0=A0=A0 f<x>();<br>=A0=A0=A0=A0=A0=A0=A0 }</span><br><span=
style=3D"font-family:courier new,monospace">=A0=A0=A0=A0=A0=A0=A0 {<br>=A0=
=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 constexpr int x =3D 2;<br>=A0=A0=A0=A0=A0=A0=
=A0=A0=A0=A0=A0 f<x>();<br>=A0=A0=A0=A0=A0=A0=A0 }</span><br>
<span style=3D"font-family:courier new,monospace">=A0=A0=A0=A0=A0=A0=A0 {<b=
r>=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 constexpr int x =3D 3;<br>=A0=A0=A0=A0=
=A0=A0=A0=A0=A0=A0=A0 f<x>();<br>=A0=A0=A0=A0=A0=A0=A0 }</span><br><s=
pan style=3D"font-family:courier new,monospace">=A0=A0=A0 }<span class=3D"H=
OEnZb"><font color=3D"#888888"><br>
<br></font></span></span></div><span class=3D"HOEnZb"><font color=3D"#88888=
8">
<p></p>
-- <br>
=A0<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%2Bunsubscribe@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>
</font></span></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 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 />
--089e016339d8d2739704e7dc1b9a--
.
Author: Andrew Tomazos <andrewtomazos@gmail.com>
Date: Thu, 3 Oct 2013 15:56:23 -0700 (PDT)
Raw View
------=_Part_48_5406402.1380840983781
Content-Type: text/plain; charset=ISO-8859-1
On Thursday, October 3, 2013 10:34:12 PM UTC+2, Richard Smith wrote:
>
> It's not true that we can't use 'constexpr' to specify a loop variable.
>
Yes, as per my followup to Daniel I meant that it isn't effectively
possible because of how range-based for is currently defined.
The semantics are as if the loop is unrolled in the obvious way.
>>
>
> If you want to force loop unrolling, it would seem much more natural to
> use a pack expansion.
>
The purpose isn't to force unrolling, the term "unrolled" is purely for
specification purposes. An implementation is free to unroll a normal loop,
and is free to rollup an "unrolled" loop. It's purely the logical
behaviour of the program that is specified.
Using a construct like 'for' would violate peoples' intuitions. 'for' does
> not usually imply code duplication,
>
The behaviour of a program containing:
for (T x : L)
and the same one instead containing:
for (constexpr T x : L)
are identical if both well-formed. So it isn't clear how it is
unintuitive. As stated the code duplication is only logical.
a 'constexpr' variable declaration can usually have only a single value
>
In the following:
template<int x>
constexpr int g()
{
constexpr int y = x*2;
return y + 5;
}
constexpr int z1 = g<3>();
constexpr int z2 = g<4>();
The `y` constexpr variable declaration has two different values, 6 and 8.
Just like in the following:
for (constexpr int x : {3,4})
{
constexpr int y = x*2;
/* ... */
}
We can think of the inner statement of the unrolled for statement as if it
were the body of a unnamed template function, and the loop variable as a
non-type template parameter. The body is instantiated and called once for
each element of the constexpr array initializer.
--
---
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposals/.
------=_Part_48_5406402.1380840983781
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr">On Thursday, October 3, 2013 10:34:12 PM UTC+2, Richard Sm=
ith wrote:<blockquote class=3D"gmail_quote" style=3D"margin: 0;margin-left:=
0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;"><div dir=3D"ltr"><di=
v>It's not true that we can't use 'constexpr' to specify a loop variable.</=
div></div></blockquote><div class=3D"gmail_quote"><br>Yes, as per my follow=
up to Daniel I meant that it isn't effectively possible because of how rang=
e-based for is currently defined.<br><br><blockquote style=3D"margin: 0px 0=
px 0px 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;=
" 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 dir=3D"ltr">The=
semantics are as if the loop is unrolled in the obvious way.<br>
</div></blockquote><div><br></div><div>If you want to force loop unrolling,=
it would seem much more natural to use a pack expansion.</div></blockquote=
><div> </div>The purpose isn't to force unrolling, the term "unrolled"=
is purely for specification purposes. An implementation is free to u=
nroll a normal loop, and is free to rollup an "unrolled" loop. It's p=
urely the logical behaviour of the program that is specified.<br><br><block=
quote style=3D"margin: 0px 0px 0px 0.8ex; border-left: 1px solid rgb(204, 2=
04, 204); padding-left: 1ex;" class=3D"gmail_quote"><div>Using a construct =
like 'for' would violate peoples' intuitions. 'for'=20
does not usually imply code duplication,</div></blockquote><div> </div=
>The behaviour of a program containing:<br><br> &nbs=
p; for (T x : L)<br><br>and the same one instead containing:<br><br> &=
nbsp; for (constexpr T x : L)<br><br>are identical if both well-forme=
d. So it isn't clear how it is unintuitive. As stated the code =
duplication is only logical.<br><br><blockquote style=3D"margin: 0px 0px 0p=
x 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;" cla=
ss=3D"gmail_quote"><div> a 'constexpr' variable=20
declaration can usually have only a single value</div>
</blockquote><div><br></div>In the following:<br><br><span style=3D"font-fa=
mily: courier new,monospace;"> template<int x></spa=
n><br><span style=3D"font-family: courier new,monospace;">  =
; constexpr int g()</span><br><span style=3D"font-family: courier new,monos=
pace;"> {</span><br><span style=3D"font-family: courier n=
ew,monospace;"> constexpr int y =
=3D x*2;</span><br><span style=3D"font-family: courier new,monospace;"></sp=
an><br><span style=3D"font-family: courier new,monospace;"> &nbs=
p; return y + 5;</span><br><span style=3D"font-fami=
ly: courier new,monospace;"> }</span><br><br><span style=
=3D"font-family: courier new,monospace;"> constexpr int z=
1 =3D g<3>();<br> constexpr int z2 =3D g<4>()=
;<br></span><br>The `y` constexpr variable declaration has two different va=
lues, 6 and 8.<br><br>Just like in the following:<br><br><span style=3D"fon=
t-family: courier new,monospace;"> for (constexpr int x :=
{3,4})<br> {<br> &nbs=
p; constexpr int y =3D x*2;<br><br> &nbs=
p; /* ... */<br> }<br></span><br>We can think of the inne=
r statement of the unrolled for statement as if it were the body of a unnam=
ed template function, and the loop variable as a non-type template paramete=
r. The body is instantiated and called once for each element of the c=
onstexpr array initializer.<br><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 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_48_5406402.1380840983781--
.
Author: Richard Smith <richard@metafoo.co.uk>
Date: Thu, 3 Oct 2013 16:17:06 -0700
Raw View
--e89a8ff24d9b65a16104e7de6276
Content-Type: text/plain; charset=ISO-8859-1
On Thu, Oct 3, 2013 at 3:56 PM, Andrew Tomazos <andrewtomazos@gmail.com>wrote:
> On Thursday, October 3, 2013 10:34:12 PM UTC+2, Richard Smith wrote:
>>
>> It's not true that we can't use 'constexpr' to specify a loop variable.
>>
>
> Yes, as per my followup to Daniel I meant that it isn't effectively
> possible because of how range-based for is currently defined.
>
It's *not* effectively impossible. To reiterate: you can pick a range type
such that the code is valid. It's just not very useful.
The semantics are as if the loop is unrolled in the obvious way.
>>>
>>
>> If you want to force loop unrolling, it would seem much more natural to
>> use a pack expansion.
>>
>
> The purpose isn't to force unrolling, the term "unrolled" is purely for
> specification purposes. An implementation is free to unroll a normal loop,
> and is free to rollup an "unrolled" loop. It's purely the logical
> behaviour of the program that is specified.
>
No, this is something different. You want the static types of elements of
the loop body to be different on different iterations, for instance. That
*forces* the loop to be fully unrolled.
> Using a construct like 'for' would violate peoples' intuitions. 'for'
>> does not usually imply code duplication,
>>
>
> The behaviour of a program containing:
>
> for (T x : L)
>
> and the same one instead containing:
>
> for (constexpr T x : L)
>
> are identical if both well-formed. So it isn't clear how it is
> unintuitive. As stated the code duplication is only logical.
>
See above.
> a 'constexpr' variable declaration can usually have only a single value
>>
>
> In the following:
>
> template<int x>
> constexpr int g()
> {
> constexpr int y = x*2;
>
> return y + 5;
> }
>
> constexpr int z1 = g<3>();
> constexpr int z2 = g<4>();
>
> The `y` constexpr variable declaration has two different values, 6 and 8.
>
Not in a single fully-instantiated function.
> Just like in the following:
>
> for (constexpr int x : {3,4})
> {
> constexpr int y = x*2;
>
> /* ... */
> }
>
> We can think of the inner statement of the unrolled for statement as if it
> were the body of a unnamed template function,
>
Right. Making it act like a template is the thing that's new and
unintuitive.
> and the loop variable as a non-type template parameter. The body is
> instantiated and called once for each element of the constexpr array
> initializer.
>
> --
>
> ---
> 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/.
--e89a8ff24d9b65a16104e7de6276
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr">On Thu, Oct 3, 2013 at 3:56 PM, Andrew Tomazos <span dir=
=3D"ltr"><<a href=3D"mailto:andrewtomazos@gmail.com" target=3D"_blank">a=
ndrewtomazos@gmail.com</a>></span> wrote:<br><div class=3D"gmail_extra">=
<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 dir=3D"ltr"><div class=3D"im">On Thursd=
ay, October 3, 2013 10:34:12 PM UTC+2, Richard Smith wrote:<blockquote clas=
s=3D"gmail_quote" style=3D"margin:0;margin-left:0.8ex;border-left:1px #ccc =
solid;padding-left:1ex">
<div dir=3D"ltr"><div>It's not true that we can't use 'constexp=
r' to specify a loop variable.</div></div></blockquote></div><div class=
=3D"gmail_quote"><br>Yes, as per my followup to Daniel I meant that it isn&=
#39;t effectively possible because of how range-based for is currently defi=
ned.<br>
</div></div></blockquote><div><br></div><div>It's *not* effectively imp=
ossible. To reiterate: you can pick a range type such that the code is vali=
d. It's just not very useful.</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"><div class=3D"gmail_quote"><blockquote style=3D"margin:0px=
0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex" cla=
ss=3D"gmail_quote"><div class=3D"im"><blockquote class=3D"gmail_quote" styl=
e=3D"margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div dir=3D"ltr">The semantics are as if the loop is unrolled in the obviou=
s way.<br>
</div></blockquote><div><br></div></div><div class=3D"im"><div>If you want =
to force loop unrolling, it would seem much more natural to use a pack expa=
nsion.</div></div></blockquote><div>=A0</div>The purpose isn't to force=
unrolling, the term "unrolled" is purely for specification purpo=
ses.=A0 An implementation is free to unroll a normal loop, and is free to r=
ollup an "unrolled" loop.=A0 It's purely the logical behaviou=
r of the program that is specified.<br>
</div></div></blockquote><div><br></div><div>No, this is something differen=
t. You want the static types of elements of the loop body to be different o=
n different iterations, for instance. That *forces* the loop to be fully un=
rolled.</div>
<div>=A0</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"><div class=3D=
"gmail_quote"><blockquote style=3D"margin:0px 0px 0px 0.8ex;border-left:1px=
solid rgb(204,204,204);padding-left:1ex" class=3D"gmail_quote">
<div>Using a construct like 'for' would violate peoples' intuit=
ions.=A0 'for'=20
does not usually imply code duplication,</div></blockquote><div>=A0</div>Th=
e behaviour of a program containing:<br><br>=A0=A0=A0=A0=A0 for (T x : L)<b=
r><br>and the same one instead containing:<br><br>=A0=A0=A0 for (constexpr =
T x : L)<br><br>
are identical if both well-formed.=A0 So it isn't clear how it is unint=
uitive.=A0 As stated the code duplication is only logical.</div></div></blo=
ckquote><div><br></div><div>See above.</div><div>=A0</div><blockquote class=
=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1px #ccc solid;padd=
ing-left:1ex">
<div dir=3D"ltr"><div class=3D"gmail_quote"><div class=3D"im"><blockquote s=
tyle=3D"margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);pad=
ding-left:1ex" class=3D"gmail_quote"><div> a 'constexpr' variable=
=20
declaration can usually have only a single value</div>
</blockquote><div><br></div></div>In the following:<br><br><span style=3D"f=
ont-family:courier new,monospace">=A0=A0=A0 template<int x></span><br=
><span style=3D"font-family:courier new,monospace">=A0=A0=A0 constexpr int =
g()</span><br>
<span style=3D"font-family:courier new,monospace">=A0=A0=A0 {</span><br><sp=
an style=3D"font-family:courier new,monospace">=A0=A0=A0=A0=A0=A0=A0 conste=
xpr int y =3D x*2;</span><br><span style=3D"font-family:courier new,monospa=
ce"></span><br><span style=3D"font-family:courier new,monospace">=A0=A0=A0=
=A0=A0=A0=A0 return y + 5;</span><br>
<span style=3D"font-family:courier new,monospace">=A0=A0=A0 }</span><br><br=
><span style=3D"font-family:courier new,monospace">=A0=A0=A0 constexpr int =
z1 =3D g<3>();<br>=A0=A0=A0 constexpr int z2 =3D g<4>();<br></s=
pan><br>The `y` constexpr variable declaration has two different values, 6 =
and 8.<br>
</div></div></blockquote><div><br></div><div>Not in a single fully-instanti=
ated function.</div><div>=A0</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">
<div class=3D"gmail_quote">Just like in the following:<br><br><span style=
=3D"font-family:courier new,monospace">=A0=A0=A0 for (constexpr int x : {3,=
4})<br>=A0=A0=A0 {<br>=A0=A0=A0=A0=A0=A0=A0 constexpr int y =3D x*2;<br><br=
>=A0=A0=A0=A0=A0=A0=A0 /* ... */<br>=A0=A0=A0 }<br>
</span><br>We can think of the inner statement of the unrolled for statemen=
t as if it were the body of a unnamed template function,</div></div></block=
quote><div><br></div><div>Right. Making it act like a template is the thing=
that's new and unintuitive.</div>
<div>=A0</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"><div class=3D=
"gmail_quote">and the loop variable as a non-type template parameter.=A0 Th=
e body is instantiated and called once for each element of the constexpr ar=
ray initializer.<br>
<br></div></div><div class=3D"HOEnZb"><div class=3D"h5">
<p></p>
-- <br>
=A0<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%2Bunsubscribe@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 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 />
--e89a8ff24d9b65a16104e7de6276--
.
Author: Andrew Tomazos <andrewtomazos@gmail.com>
Date: Thu, 3 Oct 2013 17:20:46 -0700 (PDT)
Raw View
------=_Part_92_8685140.1380846046581
Content-Type: text/plain; charset=ISO-8859-1
On Friday, October 4, 2013 1:17:06 AM UTC+2, Richard Smith wrote:
>
> On Thu, Oct 3, 2013 at 3:56 PM, Andrew Tomazos <andrew...@gmail.com<javascript:>
> > wrote:
>
>> Yes, as per my followup to Daniel I meant that it isn't effectively
>> possible because of how range-based for is currently defined.
>>
>
> It's *not* effectively impossible. To reiterate: you can pick a range type
> such that the code is valid. It's just not very useful.
>
Yes, fine. We are in violent agreement that a constexpr-specified loop
variable is currently impossible to use in a very useful way.
The purpose isn't to force unrolling, the term "unrolled" is purely for
>> specification purposes. An implementation is free to unroll a normal loop,
>> and is free to rollup an "unrolled" loop. It's purely the logical
>> behaviour of the program that is specified.
>>
>
> No, this is something different. You want the static types of elements of
> the loop body to be different on different iterations, for instance. That
> *forces* the loop to be fully unrolled.
>
In some cases, such as when there are varying static types dependant on the
loop variable it may force the loop to be unrolled, but this would be a
consequence of the intention of the code, and not grounds to claim the
construct is unintuitive.
> We can think of the inner statement of the unrolled for statement as if it
>> were the body of a unnamed template function,
>>
>
> Right. Making it act like a template is the thing that's new and
> unintuitive.
>
I think you may be conflating the unintuitive with the
difficult-to-implement.
--
---
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_92_8685140.1380846046581
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr">On Friday, October 4, 2013 1:17:06 AM UTC+2, Richard Smith=
wrote:<blockquote class=3D"gmail_quote" style=3D"margin: 0;margin-left: 0.=
8ex;border-left: 1px #ccc solid;padding-left: 1ex;"><div dir=3D"ltr">On Thu=
, Oct 3, 2013 at 3:56 PM, Andrew Tomazos <span dir=3D"ltr"><<a href=3D"j=
avascript:" target=3D"_blank" gdf-obfuscated-mailto=3D"AmbucCIKhX0J">andrew=
....@gmail.com</a>></span> wrote:<br><div><div class=3D"gmail_quote"><blo=
ckquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1px #c=
cc solid;padding-left:1ex"><div dir=3D"ltr"><div class=3D"gmail_quote">Yes,=
as per my followup to Daniel I meant that it isn't effectively possible be=
cause of how range-based for is currently defined.<br>
</div></div></blockquote><div><br></div><div>It's *not* effectively impossi=
ble. To reiterate: you can pick a range type such that the code is valid. I=
t's just not very useful.</div></div></div></div></blockquote><div> <b=
r>Yes, fine. We are in violent agreement that a constexpr-specified l=
oop variable is currently impossible to use in a very useful way.<br><br></=
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><div=
class=3D"gmail_quote"><div></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"><div class=3D"gmail_quote">The purpose isn't to force unro=
lling, the term "unrolled" is purely for specification purposes. An i=
mplementation is free to unroll a normal loop, and is free to rollup an "un=
rolled" loop. It's purely the logical behaviour of the program that i=
s specified.<br>
</div></div></blockquote><div><br></div><div>No, this is something differen=
t. You want the static types of elements of the loop body to be different o=
n different iterations, for instance. That *forces* the loop to be fully un=
rolled.</div>
<div></div></div></div></div></blockquote><div class=3D"gmail_quote"><br>In=
some cases, such as when there are varying static types dependant on the l=
oop variable it may force the loop to be unrolled, but this would be a cons=
equence of the intention of the code, and not grounds to claim the construc=
t is unintuitive.<br> <br><blockquote style=3D"margin: 0px 0px 0px 0.8=
ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;" class=3D=
"gmail_quote"><blockquote style=3D"margin: 0px 0px 0px 0.8ex; border-left: =
1px solid rgb(204, 204, 204); padding-left: 1ex;" class=3D"gmail_quote"><di=
v dir=3D"ltr"><div class=3D"gmail_quote">We can think of the inner statemen=
t of the unrolled for statement as if it were the body of a unnamed templat=
e function,</div></div></blockquote></blockquote><blockquote style=3D"margi=
n: 0px 0px 0px 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-le=
ft: 1ex;" class=3D"gmail_quote"><div><br></div><div>Right. Making it act li=
ke a template is the thing that's new and unintuitive.</div>
</blockquote><div> </div>I think you may be conflating the unintuitive=
with the difficult-to-implement.<br><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 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_92_8685140.1380846046581--
.
Author: Richard Smith <richard@metafoo.co.uk>
Date: Thu, 3 Oct 2013 18:05:17 -0700
Raw View
--047d7b07205a51af3804e7dfe5dc
Content-Type: text/plain; charset=ISO-8859-1
On Thu, Oct 3, 2013 at 5:20 PM, Andrew Tomazos <andrewtomazos@gmail.com>wrote:
> On Friday, October 4, 2013 1:17:06 AM UTC+2, Richard Smith wrote:
>
>> On Thu, Oct 3, 2013 at 3:56 PM, Andrew Tomazos <andrew...@gmail.com>wrote:
>>
>>> Yes, as per my followup to Daniel I meant that it isn't effectively
>>> possible because of how range-based for is currently defined.
>>>
>>
>> It's *not* effectively impossible. To reiterate: you can pick a range
>> type such that the code is valid. It's just not very useful.
>>
>
> Yes, fine. We are in violent agreement that a constexpr-specified loop
> variable is currently impossible to use in a very useful way.
>
> The purpose isn't to force unrolling, the term "unrolled" is purely for
>>> specification purposes. An implementation is free to unroll a normal loop,
>>> and is free to rollup an "unrolled" loop. It's purely the logical
>>> behaviour of the program that is specified.
>>>
>>
>> No, this is something different. You want the static types of elements of
>> the loop body to be different on different iterations, for instance. That
>> *forces* the loop to be fully unrolled.
>>
>
> In some cases, such as when there are varying static types dependant on
> the loop variable it may force the loop to be unrolled, but this would be a
> consequence of the intention of the code, and not grounds to claim the
> construct is unintuitive.
>
It's a consequence of the new semantics you'd be giving to the construct,
so this is a property of the construct itself, not of the code using it.
> We can think of the inner statement of the unrolled for statement as if it
>>> were the body of a unnamed template function,
>>>
>>
>> Right. Making it act like a template is the thing that's new and
>> unintuitive.
>>
>
> I think you may be conflating the unintuitive with the
> difficult-to-implement.
>
I was addressing this thread from the point of view of a user of C++, but
speaking now as a compiler implementer, I disagree. I don't *want* to
implement this, because I think it's a bad syntax, but it's not really
difficult, just weird, surprising, non-uniform, and inelegant.
The argument for this particular syntax seems to basically be "there's a
hole in the grammar here which we can jam something new into" rather than
"this is a natural extension of the existing syntax". That's a bad
argument. Using the "constexpr" keyword to mean "implicitly treat the body
of this loop like it's a template" is new and unintuitive.
That said, I think the problem is worth solving. And we already have a tool
to repeatedly stamp out multiple, slightly different, copies of the same
construct: pack expansion. That's the direction that I think should be
pursued here. Plus, any improvements there (such as allowing pack-expansion
of expression-statements, or providing pack literals) address a wide
variety of problems and fit nicely with existing language constructs,
rather than being something new and special-purpose.
--
---
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/.
--047d7b07205a51af3804e7dfe5dc
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr">On Thu, Oct 3, 2013 at 5:20 PM, Andrew Tomazos <span dir=
=3D"ltr"><<a href=3D"mailto:andrewtomazos@gmail.com" target=3D"_blank">a=
ndrewtomazos@gmail.com</a>></span> wrote:<br><div class=3D"gmail_extra">=
<div class=3D"gmail_quote">
<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">On Friday, October 4, 2013 1:17:06 AM UTC=
+2, Richard Smith wrote:<div class=3D"im">
<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">On Thu, Oct 3, 2013 at 3:56 PM, Andrew To=
mazos <span dir=3D"ltr"><<a>andrew...@gmail.com</a>></span> wrote:<br=
>
<div><div class=3D"gmail_quote"><blockquote class=3D"gmail_quote" style=3D"=
margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,20=
4,204);border-left-style:solid;padding-left:1ex"><div dir=3D"ltr"><div clas=
s=3D"gmail_quote">
Yes, as per my followup to Daniel I meant that it isn't effectively pos=
sible because of how range-based for is currently defined.<br>
</div></div></blockquote><div><br></div><div>It's *not* effectively imp=
ossible. To reiterate: you can pick a range type such that the code is vali=
d. It's just not very useful.</div></div></div></div></blockquote>
</div><div>=A0<br>Yes, fine.=A0 We are in violent agreement that a constexp=
r-specified loop variable is currently impossible to use in a very useful w=
ay.<br><br></div><div class=3D"im"><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><div class=3D"gmail_quote"><div></div><blockquote cla=
ss=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 dir=3D"ltr"><div class=3D"gmail_quote">The purpose isn't to force =
unrolling, the term "unrolled" is purely for specification purpos=
es.=A0 An implementation is free to unroll a normal loop, and is free to ro=
llup an "unrolled" loop.=A0 It's purely the logical behaviour=
of the program that is specified.<br>
</div></div></blockquote><div><br></div><div>No, this is something differen=
t. You want the static types of elements of the loop body to be different o=
n different iterations, for instance. That *forces* the loop to be fully un=
rolled.</div>
<div></div></div></div></div></blockquote></div><div class=3D"gmail_quote">=
<br>In some cases, such as when there are varying static types dependant on=
the loop variable it may force the loop to be unrolled, but this would be =
a consequence of the intention of the code, and not grounds to claim the co=
nstruct is unintuitive.</div>
</div></blockquote><div><br></div><div>It's a consequence of the new se=
mantics you'd be giving to the construct, so this is a property of the =
construct itself, not of the code using it.</div><div>=A0</div><blockquote =
class=3D"gmail_quote" style=3D"margin:0px 0px 0px 0.8ex;border-left-width:1=
px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:=
1ex">
<div dir=3D"ltr"><div class=3D"gmail_quote"><div class=3D"im"><blockquote s=
tyle=3D"margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:so=
lid;border-left-color:rgb(204,204,204);padding-left:1ex" class=3D"gmail_quo=
te"><blockquote style=3D"margin:0px 0px 0px 0.8ex;border-left-width:1px;bor=
der-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex" c=
lass=3D"gmail_quote">
<div dir=3D"ltr"><div class=3D"gmail_quote">We can think of the inner state=
ment of the unrolled for statement as if it were the body of a unnamed temp=
late function,</div></div></blockquote></blockquote><blockquote style=3D"ma=
rgin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border=
-left-color:rgb(204,204,204);padding-left:1ex" class=3D"gmail_quote">
<div><br></div><div>Right. Making it act like a template is the thing that&=
#39;s new and unintuitive.</div>
</blockquote><div>=A0</div></div>I think you may be conflating the unintuit=
ive with the difficult-to-implement.</div></div></blockquote><div><br></div=
><div>I was addressing this thread from the point of view of a user of C++,=
but speaking now as a compiler implementer, I disagree. I don't *want*=
to implement this, because I think it's a bad syntax, but it's not=
really difficult, just weird, surprising, non-uniform, and inelegant.</div=
>
<div><br></div><div>The argument for this particular syntax seems to basica=
lly be "there's a hole in the grammar here which we can jam someth=
ing new into" rather than "this is a natural extension of the exi=
sting syntax". That's a bad argument. Using the "constexpr&qu=
ot; keyword to mean "implicitly treat the body of this loop like it=
9;s a template" is new and unintuitive.</div>
<div><br></div><div>That said, I think the problem is worth solving. And we=
already have a tool to repeatedly stamp out multiple, slightly different, =
copies of the same construct: pack expansion. That's the direction that=
I think should be pursued here. Plus, any improvements there (such as allo=
wing pack-expansion of expression-statements, or providing pack literals) a=
ddress a wide variety of problems and fit nicely with existing language con=
structs, rather than being something new and special-purpose.</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 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 />
--047d7b07205a51af3804e7dfe5dc--
.
Author: Alex B <devalexb@gmail.com>
Date: Thu, 3 Oct 2013 22:40:50 -0400
Raw View
--bcaec52998b508bd8504e7e13bbf
Content-Type: text/plain; charset=ISO-8859-1
On Thu, Oct 3, 2013 at 4:15 PM, <inkwizytoryankes@gmail.com> wrote:
> Yes, it should have scope, and will not break switch because switch allow
> loops (and scopes) inside: http://en.wikipedia.org/wiki/Duff%27s_device(and it should work in C++ at least in g++ it still works).
>
>
Nice example; I have to admit that I did not know it was valid to declare
case labels in inner scopes.
I think that the "for..." syntax that you propose is a nice way to solve
the problem. Like Richard said, dealing with packs to solve this problem is
probably the right thing to do. I like the fact that your proposed syntax
allow you to choose which pack is expanded.
The one thing I still do not agree however is about break and continue
being ignored. It looks like you want to make it this way to make your
specific example work. Most programmers would expect break and continue to
apply directly to the "for..." scope (and sometime they would actually *need
* it).
Maybe you should look for an alternate solution to make your break
statement work on the switch. I saw a few suggestions about it on this
forum, like writing break twice ("break break;") or specifying an integer
to the break statement ("break(2);"). It's an old and recurrent problem
that might be worth solving in a generic way (not just by saying "ignore
break in this context").
--
---
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/.
--bcaec52998b508bd8504e7e13bbf
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr">On Thu, Oct 3, 2013 at 4:15 PM, <span dir=3D"ltr"><<a =
href=3D"mailto:inkwizytoryankes@gmail.com" target=3D"_blank">inkwizytoryank=
es@gmail.com</a>></span> wrote:<br><div class=3D"gmail_extra"><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 dir=3D"ltr">Yes, it should have scope, =
and will not break switch because switch allow loops (and scopes) inside: <=
a href=3D"http://en.wikipedia.org/wiki/Duff%27s_device" target=3D"_blank">h=
ttp://en.wikipedia.org/wiki/Duff%27s_device</a> (and it should work in C++ =
at least in g++ it still works).<br>
<br></div></blockquote><div><br></div><div>Nice example; I have to admit th=
at I did not know it was valid to declare case labels in inner scopes.</div=
><div>I think that the "for..." syntax that you propose is a nice=
way to solve the problem. Like Richard said, dealing with packs to solve t=
his problem is probably the right thing to do. I like the fact that your pr=
oposed syntax allow you to choose which pack is expanded.</div>
<div><br></div><div>The one thing I still do not agree however is about bre=
ak and continue being ignored. It looks like you want to make it this way t=
o make your specific example work. Most programmers would expect break and =
continue to apply directly to the "for..." scope (and sometime th=
ey would actually <i>need</i>=A0it).</div>
<div><br></div><div>Maybe you should look for an alternate solution to make=
your break statement work on the switch. I saw a few suggestions about it =
on this forum, like writing break twice ("break break;") or speci=
fying an integer to the break statement ("break(2);"). It's a=
n old and recurrent problem that might be worth solving in a generic way (n=
ot just by saying "ignore break in this context").</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 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 />
--bcaec52998b508bd8504e7e13bbf--
.
Author: Andrew Tomazos <andrewtomazos@gmail.com>
Date: Fri, 4 Oct 2013 03:01:49 -0700 (PDT)
Raw View
------=_Part_331_25063712.1380880909473
Content-Type: text/plain; charset=ISO-8859-1
On Friday, October 4, 2013 3:05:17 AM UTC+2, Richard Smith wrote:
> That said, I think the problem is worth solving. And we already have a
> tool to repeatedly stamp out multiple, slightly different, copies of the
> same construct: pack expansion. That's the direction that I think should be
> pursued here. Plus, any improvements there (such as allowing pack-expansion
> of expression-statements, or providing pack literals) address a wide
> variety of problems and fit nicely with existing language constructs,
> rather than being something new and special-purpose.
>
Ok, if your objections don't come from implementation-difficulty, then I
don't think we are miles apart here:
How about the following "generic for statement" syntax:
for <template-parameter : template-argument-list>
statement
This expands to:
template<template-parameter>
void __body
{
statement
}
template<template-parameter... pack>
void __repeat_body
{
__body<pack>()...;
}
// callsite
__repeat_body<template-argument-list>()
Example usage:
void f()
{
for <typename T : int, double, complex<float>>
{
T x = f(0);
T y = x*x;
g(y);
}
for <int x : 1,2,3>
h<x> = X<x>::value;
};
The main property I am interested in are that the template parameter,
template argument list and inner statement can be defined locally at call
site, without having to manually create two single-use named functions (the
first to accept the template argument list as a parameter pack, the second
to accept the template argument). You want to keep all of it together in
one place, and not have to lexically jump around through names from
different scopes - in the same spirit as a lambda or any statement that has
a sub-statement.
Discovery should go as usual left-to-range:
1. What is the construct `for<`
2. What is the parameter `template-parameter`
3. Over what list of things are we varying the parameter `:
template-argument-list`
4. What are we generating with the parameter: `statement`
If you don't like the for keyword by all means suggest another syntax, but
I think the problem is worth solving and the semantics of the construct are
worth having.
Is this closer to something you could get behind?
--
---
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_331_25063712.1380880909473
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr">On Friday, October 4, 2013 3:05:17 AM UTC+2, Richard Smith=
wrote:<br><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"><d=
iv><div class=3D"gmail_quote">That said, I think the problem is worth solvi=
ng. And we already have a tool to repeatedly stamp out multiple, slightly d=
ifferent, copies of the same construct: pack expansion. That's the directio=
n that I think should be pursued here. Plus, any improvements there (such a=
s allowing pack-expansion of expression-statements, or providing pack liter=
als) address a wide variety of problems and fit nicely with existing langua=
ge constructs, rather than being something new and special-purpose.</div></=
div></div></blockquote><div><br>Ok, if your objections don't come from impl=
ementation-difficulty, then I don't think we are miles apart here:<br><br>H=
ow about the following "generic for statement" syntax:<br><br><span style=
=3D"font-family: courier new,monospace;"> for <templat=
e-parameter : template-argument-list><br> &=
nbsp; statement<br></span><br>This expands to:<br><br><span style=3D"=
font-family: courier new,monospace;"> template<templat=
e-parameter><br> void __body<br> {<b=
r> statement<br> =
; }<br><br> template<template-parameter...=
pack><br> void __repeat_body<br> {<=
br> __body<pack>()...;<br>&=
nbsp; }<br><br> // callsite<br> =
__repeat_body<template-argument-list>()<br></span><br>Example usage:<=
br><br><span style=3D"font-family: courier new,monospace;"> &nbs=
p; void f()<br> =
{<br> &nb=
sp; for <typename T : int, double, complex<float>><br> &nb=
sp; {<br> =
&nb=
sp; T x =3D f(0);<br> =
T y =3D x*x;<br> &nbs=
p; &=
nbsp; g(y);<br> =
}<br><br>  =
; for <int x : 1,2,3><br> &n=
bsp; h<x>=
=3D X<x>::value;<br> };<br=
></span><br>The main property I am interested in are that the template para=
meter, template argument list and inner statement can be defined locally at=
call site, without having to manually create two single-use named function=
s (the first to accept the template argument list as a parameter pack, the =
second to accept the template argument). You want to keep all of it t=
ogether in one place, and not have to lexically jump around through names f=
rom different scopes - in the same spirit as a lambda or any statement that=
has a sub-statement.<br><br>Discovery should go as usual left-to-range:<br=
><br>1. What is the construct `for<`<br>2. What is the parameter `templa=
te-parameter`<br>3. Over what list of things are we varying the parameter `=
: template-argument-list`<br>4. What are we generating with the parameter: =
`statement`<br><br>If you don't like the for keyword by all means suggest a=
nother syntax, but I think the problem is worth solving and the semantics o=
f the construct are worth having.<br><br>Is this closer to something you co=
uld get behind?<br><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 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_331_25063712.1380880909473--
.
Author: inkwizytoryankes@gmail.com
Date: Fri, 4 Oct 2013 10:59:55 -0700 (PDT)
Raw View
------=_Part_277_6142748.1380909596062
Content-Type: text/plain; charset=ISO-8859-1
This specific example is reason why I want add this syntax. I treat this
more like "copypaste" than normal loop.
Syntax like `break break;` or `break continue;` would be best compromise.
But even if this wont pass and `foo...` will ignore (or not) `break` and
`continue` we can still use `goto` to work around it.
This bring me to conclusion that `for...` should behave like you want,
because one `goto` is small price to pay for possibles that `for...` give.
And when we speaking about `goto`, labels inside `for...` shloud be treat
as private, you wont be able jump to them from outside of `for...` scope.
Its simply because every label in `for...` is "copied" multiple times.
Sometimes it can be no label at all if pack was empty.
On Friday, October 4, 2013 4:40:50 AM UTC+2, Alex B wrote:
>
> On Thu, Oct 3, 2013 at 4:15 PM, <inkwizyt...@gmail.com <javascript:>>wrote:
>
>> Yes, it should have scope, and will not break switch because switch allow
>> loops (and scopes) inside: http://en.wikipedia.org/wiki/Duff%27s_device(and it should work in C++ at least in g++ it still works).
>>
>>
> Nice example; I have to admit that I did not know it was valid to declare
> case labels in inner scopes.
> I think that the "for..." syntax that you propose is a nice way to solve
> the problem. Like Richard said, dealing with packs to solve this problem is
> probably the right thing to do. I like the fact that your proposed syntax
> allow you to choose which pack is expanded.
>
> The one thing I still do not agree however is about break and continue
> being ignored. It looks like you want to make it this way to make your
> specific example work. Most programmers would expect break and continue to
> apply directly to the "for..." scope (and sometime they would actually *
> need* it).
>
> Maybe you should look for an alternate solution to make your break
> statement work on the switch. I saw a few suggestions about it on this
> forum, like writing break twice ("break break;") or specifying an integer
> to the break statement ("break(2);"). It's an old and recurrent problem
> that might be worth solving in a generic way (not just by saying "ignore
> break in this context").
>
--
---
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_277_6142748.1380909596062
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr">This specific example is reason why I want add this syntax=
.. I treat this more like "copypaste" than normal loop.<br>Syntax like `brea=
k break;` or `break continue;` would be best compromise. But even if this w=
ont pass and `foo...` will ignore (or not) `break` and `continue` we can st=
ill use `goto` to work around it.<br>This bring me to conclusion that `for.=
...` should behave like you want, because one `goto` is small price to pay f=
or possibles that `for...` give.<br><br>And when we speaking about `goto`, =
labels inside `for...` shloud be treat as private, you wont be able jump to=
them from outside of `for...` scope.<br>Its simply because every label in =
`for...` is "copied" multiple times. Sometimes it can be no label at all if=
pack was empty.<br><br>On Friday, October 4, 2013 4:40:50 AM UTC+2, Alex B=
wrote:<blockquote class=3D"gmail_quote" style=3D"margin: 0;margin-left: 0.=
8ex;border-left: 1px #ccc solid;padding-left: 1ex;"><div dir=3D"ltr">On Thu=
, Oct 3, 2013 at 4:15 PM, <span dir=3D"ltr"><<a href=3D"javascript:" ta=
rget=3D"_blank" gdf-obfuscated-mailto=3D"v8nCUTrzDjoJ">inkwizyt...@gmail.co=
m</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 dir=3D"ltr">Yes, it should have scope, =
and will not break switch because switch allow loops (and scopes) inside: <=
a href=3D"http://en.wikipedia.org/wiki/Duff%27s_device" target=3D"_blank">h=
ttp://en.wikipedia.org/wiki/<wbr>Duff%27s_device</a> (and it should work in=
C++ at least in g++ it still works).<br>
<br></div></blockquote><div><br></div><div>Nice example; I have to admit th=
at I did not know it was valid to declare case labels in inner scopes.</div=
><div>I think that the "for..." syntax that you propose is a nice way to so=
lve the problem. Like Richard said, dealing with packs to solve this proble=
m is probably the right thing to do. I like the fact that your proposed syn=
tax allow you to choose which pack is expanded.</div>
<div><br></div><div>The one thing I still do not agree however is about bre=
ak and continue being ignored. It looks like you want to make it this way t=
o make your specific example work. Most programmers would expect break and =
continue to apply directly to the "for..." scope (and sometime they would a=
ctually <i>need</i> it).</div>
<div><br></div><div>Maybe you should look for an alternate solution to make=
your break statement work on the switch. I saw a few suggestions about it =
on this forum, like writing break twice ("break break;") or specifying an i=
nteger to the break statement ("break(2);"). It's an old and recurrent prob=
lem that might be worth solving in a generic way (not just by saying "ignor=
e break in this context").</div>
</div></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 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_277_6142748.1380909596062--
.
Author: inkwizytoryankes@gmail.com
Date: Fri, 4 Oct 2013 11:34:19 -0700 (PDT)
Raw View
------=_Part_214_24200602.1380911659263
Content-Type: text/plain; charset=ISO-8859-1
Using `<>` is probably to drastic, is any language in C family that use
them in similar fashion? D even replace them in templates (you write
`Type!(A, B)` if you want something like `Type<A, B>`).
On Friday, October 4, 2013 12:01:49 PM UTC+2, Andrew Tomazos wrote:
>
> On Friday, October 4, 2013 3:05:17 AM UTC+2, Richard Smith wrote:
>
>> That said, I think the problem is worth solving. And we already have a
>> tool to repeatedly stamp out multiple, slightly different, copies of the
>> same construct: pack expansion. That's the direction that I think should be
>> pursued here. Plus, any improvements there (such as allowing pack-expansion
>> of expression-statements, or providing pack literals) address a wide
>> variety of problems and fit nicely with existing language constructs,
>> rather than being something new and special-purpose.
>>
>
> Ok, if your objections don't come from implementation-difficulty, then I
> don't think we are miles apart here:
>
> How about the following "generic for statement" syntax:
>
> for <template-parameter : template-argument-list>
> statement
>
> This expands to:
>
> template<template-parameter>
> void __body
> {
> statement
> }
>
> template<template-parameter... pack>
> void __repeat_body
> {
> __body<pack>()...;
> }
>
> // callsite
> __repeat_body<template-argument-list>()
>
> Example usage:
>
> void f()
> {
> for <typename T : int, double, complex<float>>
> {
> T x = f(0);
> T y = x*x;
> g(y);
> }
>
> for <int x : 1,2,3>
> h<x> = X<x>::value;
> };
>
> The main property I am interested in are that the template parameter,
> template argument list and inner statement can be defined locally at call
> site, without having to manually create two single-use named functions (the
> first to accept the template argument list as a parameter pack, the second
> to accept the template argument). You want to keep all of it together in
> one place, and not have to lexically jump around through names from
> different scopes - in the same spirit as a lambda or any statement that has
> a sub-statement.
>
> Discovery should go as usual left-to-range:
>
> 1. What is the construct `for<`
> 2. What is the parameter `template-parameter`
> 3. Over what list of things are we varying the parameter `:
> template-argument-list`
> 4. What are we generating with the parameter: `statement`
>
> If you don't like the for keyword by all means suggest another syntax, but
> I think the problem is worth solving and the semantics of the construct are
> worth having.
>
> Is this closer to something you could get behind?
>
>
--
---
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_214_24200602.1380911659263
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr">Using `<>` is probably to drastic, is any language i=
n C family that use them in similar fashion? D even replace them in templat=
es (you write `Type!(A, B)` if you want something like `Type<A, B>`).=
<br><br>On Friday, October 4, 2013 12:01:49 PM UTC+2, Andrew Tomazos wrote:=
<blockquote class=3D"gmail_quote" style=3D"margin: 0;margin-left: 0.8ex;bor=
der-left: 1px #ccc solid;padding-left: 1ex;"><div dir=3D"ltr">On Friday, Oc=
tober 4, 2013 3:05:17 AM UTC+2, Richard Smith wrote:<br><blockquote class=
=3D"gmail_quote" style=3D"margin:0;margin-left:0.8ex;border-left:1px #ccc s=
olid;padding-left:1ex"><div dir=3D"ltr"><div><div class=3D"gmail_quote">Tha=
t said, I think the problem is worth solving. And we already have a tool to=
repeatedly stamp out multiple, slightly different, copies of the same cons=
truct: pack expansion. That's the direction that I think should be pursued =
here. Plus, any improvements there (such as allowing pack-expansion of expr=
ession-statements, or providing pack literals) address a wide variety of pr=
oblems and fit nicely with existing language constructs, rather than being =
something new and special-purpose.</div></div></div></blockquote><div><br>O=
k, if your objections don't come from implementation-difficulty, then I don=
't think we are miles apart here:<br><br>How about the following "generic f=
or statement" syntax:<br><br><span style=3D"font-family:courier new,monospa=
ce"> for <template-parameter : template-argument-list&=
gt;<br> statement<br></span><br>T=
his expands to:<br><br><span style=3D"font-family:courier new,monospace">&n=
bsp; template<template-parameter><br> v=
oid __body<br> {<br> &=
nbsp; statement<br> }<br><br> &nbs=
p; template<template-parameter... pack><br> void __=
repeat_body<br> {<br> =
__body<pack>()...;<br> }<br><br> =
// callsite<br> __repeat_body<template-<wbr>argument=
-list>()<br></span><br>Example usage:<br><br><span style=3D"font-family:=
courier new,monospace"> void f()<=
br> {<br> =
for <typename T : int, double=
, complex<float>><br> &nb=
sp; {<br> =
T x =3D f(0);<br> &nb=
sp; =
T y =3D x*x;<br> &nbs=
p; g(y);<br> &nb=
sp; }<br><br> &n=
bsp; for <int x : 1,2,3&=
gt;<br> &n=
bsp; h<x> =3D X<x>::value;<br> &nb=
sp; };<br></span><br>The main property I am i=
nterested in are that the template parameter, template argument list and in=
ner statement can be defined locally at call site, without having to manual=
ly create two single-use named functions (the first to accept the template =
argument list as a parameter pack, the second to accept the template argume=
nt). You want to keep all of it together in one place, and not have t=
o lexically jump around through names from different scopes - in the same s=
pirit as a lambda or any statement that has a sub-statement.<br><br>Discove=
ry should go as usual left-to-range:<br><br>1. What is the construct `for&l=
t;`<br>2. What is the parameter `template-parameter`<br>3. Over what list o=
f things are we varying the parameter `: template-argument-list`<br>4. What=
are we generating with the parameter: `statement`<br><br>If you don't like=
the for keyword by all means suggest another syntax, but I think the probl=
em is worth solving and the semantics of the construct are worth having.<br=
><br>Is this closer to something you could get behind?<br><br></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 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_214_24200602.1380911659263--
.
Author: Andrew Tomazos <andrewtomazos@gmail.com>
Date: Fri, 4 Oct 2013 13:11:25 -0700 (PDT)
Raw View
------=_Part_369_24862092.1380917485541
Content-Type: text/plain; charset=ISO-8859-1
Angle brackets delimit template argument lists and template parameter lists
in C++. The purpose of using them in the construct, apart from consistency
with that clear precedent, is to address Richards concern that the user may
not realize it is a generic for loop, and as such implies code duplication
when types vary significantly between loops.
On Friday, October 4, 2013 8:34:19 PM UTC+2, inkwizyt...@gmail.com wrote:
>
> Using `<>` is probably to drastic, is any language in C family that use
> them in similar fashion? D even replace them in templates (you write
> `Type!(A, B)` if you want something like `Type<A, B>`).
>
> On Friday, October 4, 2013 12:01:49 PM UTC+2, Andrew Tomazos wrote:
>>
>> On Friday, October 4, 2013 3:05:17 AM UTC+2, Richard Smith wrote:
>>
>>> That said, I think the problem is worth solving. And we already have a
>>> tool to repeatedly stamp out multiple, slightly different, copies of the
>>> same construct: pack expansion. That's the direction that I think should be
>>> pursued here. Plus, any improvements there (such as allowing pack-expansion
>>> of expression-statements, or providing pack literals) address a wide
>>> variety of problems and fit nicely with existing language constructs,
>>> rather than being something new and special-purpose.
>>>
>>
>> Ok, if your objections don't come from implementation-difficulty, then I
>> don't think we are miles apart here:
>>
>> How about the following "generic for statement" syntax:
>>
>> for <template-parameter : template-argument-list>
>> statement
>>
>> This expands to:
>>
>> template<template-parameter>
>> void __body
>> {
>> statement
>> }
>>
>> template<template-parameter... pack>
>> void __repeat_body
>> {
>> __body<pack>()...;
>> }
>>
>> // callsite
>> __repeat_body<template-argument-list>()
>>
>> Example usage:
>>
>> void f()
>> {
>> for <typename T : int, double, complex<float>>
>> {
>> T x = f(0);
>> T y = x*x;
>> g(y);
>> }
>>
>> for <int x : 1,2,3>
>> h<x> = X<x>::value;
>> };
>>
>> The main property I am interested in are that the template parameter,
>> template argument list and inner statement can be defined locally at call
>> site, without having to manually create two single-use named functions (the
>> first to accept the template argument list as a parameter pack, the second
>> to accept the template argument). You want to keep all of it together in
>> one place, and not have to lexically jump around through names from
>> different scopes - in the same spirit as a lambda or any statement that has
>> a sub-statement.
>>
>> Discovery should go as usual left-to-range:
>>
>> 1. What is the construct `for<`
>> 2. What is the parameter `template-parameter`
>> 3. Over what list of things are we varying the parameter `:
>> template-argument-list`
>> 4. What are we generating with the parameter: `statement`
>>
>> If you don't like the for keyword by all means suggest another syntax,
>> but I think the problem is worth solving and the semantics of the construct
>> are worth having.
>>
>> Is this closer to something you could get behind?
>>
>>
--
---
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_369_24862092.1380917485541
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr">Angle brackets delimit template argument lists and templat=
e parameter lists in C++. The purpose of using them in the construct,=
apart from consistency with that clear precedent, is to address Richards c=
oncern that the user may not realize it is a generic for loop, and as such =
implies code duplication when types vary significantly between loops.<br><b=
r>On Friday, October 4, 2013 8:34:19 PM UTC+2, inkwizyt...@gmail.com wrote:=
<blockquote class=3D"gmail_quote" style=3D"margin: 0;margin-left: 0.8ex;bor=
der-left: 1px #ccc solid;padding-left: 1ex;"><div dir=3D"ltr">Using `<&g=
t;` is probably to drastic, is any language in C family that use them in si=
milar fashion? D even replace them in templates (you write `Type!(A, B)` if=
you want something like `Type<A, B>`).<br><br>On Friday, October 4, =
2013 12:01:49 PM UTC+2, Andrew Tomazos wrote:<blockquote class=3D"gmail_quo=
te" style=3D"margin:0;margin-left:0.8ex;border-left:1px #ccc solid;padding-=
left:1ex"><div dir=3D"ltr">On Friday, October 4, 2013 3:05:17 AM UTC+2, Ric=
hard Smith wrote:<br><blockquote class=3D"gmail_quote" style=3D"margin:0;ma=
rgin-left:0.8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir=3D"lt=
r"><div><div class=3D"gmail_quote">That said, I think the problem is worth =
solving. And we already have a tool to repeatedly stamp out multiple, sligh=
tly different, copies of the same construct: pack expansion. That's the dir=
ection that I think should be pursued here. Plus, any improvements there (s=
uch as allowing pack-expansion of expression-statements, or providing pack =
literals) address a wide variety of problems and fit nicely with existing l=
anguage constructs, rather than being something new and special-purpose.</d=
iv></div></div></blockquote><div><br>Ok, if your objections don't come from=
implementation-difficulty, then I don't think we are miles apart here:<br>=
<br>How about the following "generic for statement" syntax:<br><br><span st=
yle=3D"font-family:courier new,monospace"> for <templa=
te-parameter : template-argument-list><br> =
statement<br></span><br>This expands to:<br><br><span style=3D=
"font-family:courier new,monospace"> template<template=
-parameter><br> void __body<br> {<br=
> statement<br> =
}<br><br> template<template-parameter... =
pack><br> void __repeat_body<br> {<b=
r> __body<pack>()...;<br>&n=
bsp; }<br><br> // callsite<br> _=
_repeat_body<template-<wbr>argument-list>()<br></span><br>Example usa=
ge:<br><br><span style=3D"font-family:courier new,monospace"> &n=
bsp; void f()<br> &nbs=
p; {<br> &=
nbsp; for <typename T : int, double, complex<float>><br> &=
nbsp; {<br> &nbs=
p; &=
nbsp; T x =3D f(0);<br> &nbs=
p; T y =3D x*x;<br> &n=
bsp;  =
; g(y);<br> &nbs=
p; }<br><br> &nb=
sp; for <int x : 1,2,3><br> =
h<x&g=
t; =3D X<x>::value;<br> };<=
br></span><br>The main property I am interested in are that the template pa=
rameter, template argument list and inner statement can be defined locally =
at call site, without having to manually create two single-use named functi=
ons (the first to accept the template argument list as a parameter pack, th=
e second to accept the template argument). You want to keep all of it=
together in one place, and not have to lexically jump around through names=
from different scopes - in the same spirit as a lambda or any statement th=
at has a sub-statement.<br><br>Discovery should go as usual left-to-range:<=
br><br>1. What is the construct `for<`<br>2. What is the parameter `temp=
late-parameter`<br>3. Over what list of things are we varying the parameter=
`: template-argument-list`<br>4. What are we generating with the parameter=
: `statement`<br><br>If you don't like the for keyword by all means suggest=
another syntax, but I think the problem is worth solving and the semantics=
of the construct are worth having.<br><br>Is this closer to something you =
could get behind?<br><br></div></div></blockquote></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 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_369_24862092.1380917485541--
.
Author: inkwizytoryankes@gmail.com
Date: Fri, 4 Oct 2013 15:05:02 -0700 (PDT)
Raw View
------=_Part_503_31201162.1380924302515
Content-Type: text/plain; charset=ISO-8859-1
My question was probably not accurate, my point was that this will be first
time when angle brackets are used as part flow control syntax in C-family
languages.
I would prefer `static for` or my `for...` to distinguish both usages and
leave round brackets.
Another problem is that syntax cant be used directly in macros because it
treat them as operators not brackets (its already problem with templates,
expanding it isnt probably good idea).
On Friday, October 4, 2013 10:11:25 PM UTC+2, Andrew Tomazos wrote:
>
> Angle brackets delimit template argument lists and template parameter
> lists in C++. The purpose of using them in the construct, apart from
> consistency with that clear precedent, is to address Richards concern that
> the user may not realize it is a generic for loop, and as such implies code
> duplication when types vary significantly between loops.
>
> On Friday, October 4, 2013 8:34:19 PM UTC+2, inkwizyt...@gmail.com wrote:
>>
>> Using `<>` is probably to drastic, is any language in C family that use
>> them in similar fashion? D even replace them in templates (you write
>> `Type!(A, B)` if you want something like `Type<A, B>`)
>>
>>
--
---
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_503_31201162.1380924302515
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr">My question was probably not accurate, my point was that t=
his will be first time when angle brackets are used as part flow control sy=
ntax in C-family languages.<br>I would prefer `static for` or my `for=
....` to distinguish both usages and leave round brackets. <br>Another probl=
em is that syntax cant be used directly in macros because it treat them as =
operators not brackets (its already problem with templates, expanding it is=
nt probably good idea).<br><br>On Friday, October 4, 2013 10:11:25 PM UTC+2=
, Andrew Tomazos wrote:<blockquote class=3D"gmail_quote" style=3D"margin: 0=
;margin-left: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;"><div di=
r=3D"ltr">Angle brackets delimit template argument lists and template param=
eter lists in C++. The purpose of using them in the construct, apart =
from consistency with that clear precedent, is to address Richards concern =
that the user may not realize it is a generic for loop, and as such implies=
code duplication when types vary significantly between loops.<br><br>On Fr=
iday, October 4, 2013 8:34:19 PM UTC+2, <a>inkwizyt...@gmail.com</a> wrote:=
<blockquote class=3D"gmail_quote" style=3D"margin:0;margin-left:0.8ex;borde=
r-left:1px #ccc solid;padding-left:1ex"><div dir=3D"ltr">Using `<>` i=
s probably to drastic, is any language in C family that use them in similar=
fashion? D even replace them in templates (you write `Type!(A, B)` if you =
want something like `Type<A, B>`)<div dir=3D"ltr"><div><br></div></di=
v></div></blockquote></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 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_503_31201162.1380924302515--
.