Topic: -1?Q?[std-proposals] Re: Question for Germ n Diago: N413


Author: =?UTF-8?Q?Germ=C3=A1n_Diago?= <germandiago@gmail.com>
Date: Sat, 25 Oct 2014 02:47:22 -0700 (PDT)
Raw View
------=_Part_648_1420756984.1414230442448
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

Disclaimer: I don't claim to fully understand both proposals yet.

Hello Gor Nishanov,

I was taking a look at both papers again. I think, as you said in your=20
comment in youtube, that they are similar in performance.

However, without being an expert on the matter, I find two key differences=
=20
in both:

1. In my opinion, N4244 seems easier to reason about in the sense that I do=
=20
know what is happening under the hood, because
everything is modeled after a lambda. I do understand this model and I am=
=20
confident is as lightweight as it can be.

2. In N4244 it mentions: "17.1 Unspecified memory representation".
I am concerned about this and how normal stateless functions are handled=20
when await/yield is found:=20

do we need runtime support?

AFAIK, functions are stateless, so this info must be somewhere.=20
A resumable lambda from N4244 is stateful, I know what happens under the=20
hood: it is just a capture list.

For example, from N4134:

auto squares =3D [&]{ for(x:S) yield x*x;} ;

With n4244 in my hands, I can completely figure out what is happening=20
there: it is just a function object, I can easily
see how lightweight this gets, since it is equivalent to a hand-coded=20
function object + sizeof(x + S ref) + sizeof(resumable_point),
if I am not wrong.

How is this translated in your proposal, about object size, etc? Maybe it=
=20
is the same, my problem is that it is more
difficult for me to follow and understand :) So I apologize if they are=20
equivalent.

Another example:

template<class T>
async_generator<pair<T, system_clock::time_point>>
Timestamp(async_read_stream<T> S)=20
{
    for await(v: S) yield {v, system_clock::now()};
}

I can't figure out how this is implemented. Sorry if I don't fully=20
understand things yet.

My point here is also, that I find resumable lambdas very easy to reason=20
about, I could do it in a few minutes.
The problem I find with the design in your paper, which I also like a lot,=
=20
is that I find it more difficult to reason about
what is happening under the hood.

Regards,
Germ=C3=A1n Diago G=C3=B3mez


El s=C3=A1bado, 25 de octubre de 2014 10:43:14 UTC+7, Gor Nishanov escribi=
=C3=B3:
>
> Hi Germ=C3=A1n:
>
> You mentioned in a youtube comment that you are concerned about efficienc=
y=20
> of N4134 as compared to that of N4244. I am wondering if you have a=20
> particular example in mind. I am very interested in learning what do you=
=20
> think are the weak points of N4134 as compared to N4134.
>
> Thank you,
> Gor
>
>

--=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_648_1420756984.1414230442448
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr">Disclaimer: I don't claim to fully understand both proposa=
ls yet.<div><br></div><div>Hello Gor Nishanov,</div><div><br></div><div>I w=
as taking a look at both papers again. I think, as you said in your comment=
 in youtube, that they are similar in performance.</div><div><br></div><div=
>However, without being an expert on the matter, I find two key differences=
 in both:</div><div><br></div><div>1. In my opinion, N4244 seems easier to =
reason about in the sense that I do know what is happening under the hood, =
because</div><div>everything is modeled after a lambda. I do understand thi=
s model and I am confident is as lightweight as it can be.</div><div><br></=
div><div>2. In N4244 it mentions: "17.1 Unspecified memory representation".=
</div><div>I am concerned about this and how normal stateless functions are=
 handled when await/yield is found:&nbsp;</div><div><br></div><div>do we ne=
ed runtime support?</div><div><br></div><div>AFAIK, functions are stateless=
, so this info must be somewhere.&nbsp;</div><div>A resumable lambda from N=
4244 is stateful, I know what happens under the hood: it is just a capture =
list.</div><div><br></div><div>For example, from N4134:</div><div><br></div=
><div>auto squares =3D [&amp;]{ for(x:S) yield x*x;} ;</div><div><br></div>=
<div>With&nbsp;n4244 in my hands, I can completely figure out what is happe=
ning there: it is just a function object, I can easily</div><div>see how li=
ghtweight this gets, since it is equivalent to a hand-coded function object=
 + sizeof(x + S ref) + sizeof(resumable_point),</div><div>if I am not wrong=
..</div><div><br></div><div>How is this translated in your proposal, about o=
bject size, etc? Maybe it is the same, my problem is that it is more</div><=
div>difficult for me to follow and understand :) So I apologize if they are=
 equivalent.</div><div><br></div><div>Another example:</div><div><br></div>=
<div><div>template&lt;class T&gt;</div><div>async_generator&lt;pair&lt;T, s=
ystem_clock::time_point&gt;&gt;</div><div>Timestamp(async_read_stream&lt;T&=
gt; S)&nbsp;</div><div>{</div><div>&nbsp; &nbsp; for await(v: S) yield {v, =
system_clock::now()};</div><div>}</div></div><div><br></div><div>I can't fi=
gure out how this is implemented. Sorry if I don't fully understand things =
yet.</div><div><br></div><div>My point here is also, that I find resumable =
lambdas very easy to reason about, I could do it in a few minutes.</div><di=
v>The problem I find with the design in your paper, which I also like a lot=
, is that I find it more difficult to reason about</div><div>what is happen=
ing under the hood.</div><div><br></div><div>Regards,</div><div>Germ=C3=A1n=
 Diago G=C3=B3mez</div><div><br></div><div><br></div><div>El s=C3=A1bado, 2=
5 de octubre de 2014 10:43:14 UTC+7, Gor Nishanov  escribi=C3=B3:<blockquot=
e 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>Hi Germ=C3=A1n:</d=
iv><div><br></div><div>You mentioned in a youtube comment that you are conc=
erned about efficiency of N4134 as compared to that of N4244. I am wonderin=
g if you have&nbsp;a particular example in mind. I am very interested in le=
arning what do you think are&nbsp;the&nbsp;weak points of N4134 as compared=
 to N4134.</div><div><br></div><div>Thank you,</div><div>Gor<br><br></div><=
/div></blockquote></div></div>

<p></p>

-- <br />
<br />
--- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals&quot; group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<br />
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/">http://groups.google.com/a/isocpp.org/group/std-proposals/<=
/a>.<br />

------=_Part_648_1420756984.1414230442448--

.


Author: =?UTF-8?Q?Germ=C3=A1n_Diago?= <germandiago@gmail.com>
Date: Sat, 25 Oct 2014 02:58:08 -0700 (PDT)
Raw View
------=_Part_1737_2112548582.1414231088450
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

Forgot one question:

Are both implementations equivalente in expressive power?

Regards,
Germ=C3=A1n Diago G=C3=B3mez

--=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_1737_2112548582.1414231088450
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr">Forgot one question:<div><br></div><div>Are both implement=
ations equivalente in expressive power?</div><div><br></div><div>Regards,</=
div><div>Germ=C3=A1n Diago G=C3=B3mez</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&quot; group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<br />
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/">http://groups.google.com/a/isocpp.org/group/std-proposals/<=
/a>.<br />

------=_Part_1737_2112548582.1414231088450--

.


Author: Gor Nishanov <gornishanov@gmail.com>
Date: Sat, 25 Oct 2014 07:30:14 -0700 (PDT)
Raw View
------=_Part_1911_1339040544.1414247414034
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

=20
  =20
   1.=20
  =20
   Unspecified memory representation. That is a criticism of N3977 and=20
   inapplicable to N4134.
  =20
   2.=20
  =20
   Does N4134 need runtime support?
  =20
   As much run-time support as range-based for. At compile time we look up=
=20
   await_xxx functions that explain how to await on a particular expression=
..=20
   This is similar how range-based for looks up begin/end to understand how=
 to=20
   iterate over a range
  =20
 3. Difficult to reason about: "In my opinion, N4244 seems easier to reason=
=20
about in the sense that I do know what is happening under the hood, because=
=20
everything is modeled after a lambda. I do understand this model and I am=
=20
confident is as lightweight as it can be.=20

=20

I started the design on N4134, with an attempt to generalize the lambda. I=
=20
called it lambda*. This lambda*=E2=80=99s closure would contain not only th=
e=20
capture, but also a room for all the locals in the body of operator().=20
Essentially, same idea as N4244. However, when applying to different=20
patterns, it seemed to me that nearly always it needed to be wrapped in=20
some kind of helper function that frequently need to allocate the memory=20
for lambda somewhere to give it a stable location.

You can think of N4134 is a syntactic sugar wrapper around a lambda, such=
=20
as in N4244.

In case, where lifetime of a coroutine is fully contained in the lifetime=
=20
of a calling function, heap allocation is elided and it becomes exactly the=
=20
lambda*.

I did not find a case where I needed to expose lambda* itself.=20

=20
=20
template<class T>

async_generator<pair<T, system_clock::time_point>>

Timestamp(async_read_stream<T> S)=20

{

    for await(v: S) yield {v, system_clock::now()};
}
the body states very succinctly what it is doing. For every v received from=
=20
S yield a pair of values v received and a timestamp when it was received. I=
=20
can also rewrite it as:

auto Timestamp(async_read_stream<T> S)  {

    for await(v: S) yield make_pair(v, system_clock::now());
}

If you want to know what happens "under the hood" for await-for a yield,=20
look for the details in N4134.

=20

On page 16 of N4134, you can see the expansion of await-for which is nearly=
=20
the same as range-based for with the exception that every =E2=80=9Casyn pul=
l=E2=80=9D=20
operation is annotated with =E2=80=9Cawait=E2=80=9D

=20

*for await *( for-range-declaration : *expression *) statement

=20

     is equivalent to

=20

{

*auto *&& __range =3D *expression*;

*for *( *auto *__begin =3D *await *begin-expr,

__end =3D end-expr;

__begin !=3D __end;

*await *++__begin )

{

*for-range-declaration *=3D *__begin;

statement

}

}

On page 15, there is a decription of what happens for yield:

A yield statement is a statement of form:

*yield **expression*;

or

*yield **braced-init-list*;

yield <something>; is equivalent to

(void)(await <Promise>.yield_value(<something>))

Where a <Promise> refers to the coroutine promise of the enclosing=20
resumable function.


>> I can't figure out how this is implemented. Sorry if I don't fully=20
understand things yet.

Think of N4134 as range-based for on steroids. It is mostly syntactic sugar=
=20
and efficient suspend and resume giving the library designer to imbue=20
coroutines with meaning.=20

=20

Full implementation of generator is listed in Appendix A of N4134, also,=20
you can find there adapters to boost::futures and other things.

=20

Are both implementations equivalente in expressive power?

In my, biased, J view. N4134 can solve any problem that N4244 can with=20
shorter code and the same or better performance. The opposite is not true.

Also, N4134 machinery is applicable to other problems domain, besides=20
coroutine and async. For example, Geoffrey Romer noticed that he can adapt=
=20
await to simplify working with monadic classes such as optional.

=20

optional<Foo> FooSource();
optional<Bar> BarFromFoo(const Foo&);
~~~~~~~~~~~~~~~~~~~~~~~~~~ with await ~~~~~~~~~~
optional<Baz> f() {
  Bar bar =3D await BarFromFoo(await FooSource());
  Baz baz;
  // Compute baz from bar
  return baz;
}
~~~~~~~~~~~~~~~~~~~~~~~~~~~without await ~~~~~~~~
optional<Baz> f() {
  optional<Foo> foo =3D FooSource();

  if (!foo) {

    return nullopt;

  }

  optional<Bar> bar =3D BarFromFoo(*foo);

  if (!bar) {

    return nullopt;

  }

  Baz baz;

  // Compute baz from *bar

  return baz;

}

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

=20


On Saturday, October 25, 2014 2:58:08 AM UTC-7, Germ=C3=A1n Diago wrote:
>
> Forgot one question:
>
> Are both implementations equivalente in expressive power?
>
> Regards,
> Germ=C3=A1n Diago G=C3=B3mez
>

--=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_1911_1339040544.1414247414034
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><font color=3D"#000000" face=3D"Times New Roman" size=3D"3=
">

</font><ol style=3D"list-style-type: decimal; direction: ltr;"><li style=3D=
"font-style: normal; font-weight: normal;"><p style=3D"font-style: normal; =
font-weight: normal; margin-top: 0in; margin-bottom: 0pt; mso-list: l0 leve=
l1 lfo1;">Unspecified memory representation. That is a criticism
of N3977 and inapplicable to N4134.<br><br></p></li><li style=3D"font-style=
: normal; font-weight: normal;"><p style=3D"font-style: normal; font-weight=
: normal; margin-top: 0in; margin-bottom: 0pt; mso-list: l0 level1 lfo1;">D=
oes&nbsp;N4134 need runtime support?<br><br>As much run-time support as ran=
ge-based for. At
compile time we look up await_xxx functions that explain how to await on a
particular expression. This is similar how range-based for looks up begin/e=
nd
to understand how to iterate over a range</p></li></ol><font color=3D"#0000=
00" face=3D"Times New Roman" size=3D"3">





</font><font color=3D"#000000" face=3D"Times New Roman" size=3D"3">
</font><span style=3D'color: rgb(34, 34, 34); font-family: "Arial","sans-se=
rif"; font-size: 10pt; mso-fareast-font-family: "Times New Roman";'>3. Diff=
icult to reason about: "In my opinion, N4244
seems easier to reason about in the sense that I do know what is happening
under the hood, because everything is modeled after a lambda. I do understa=
nd
this model and I am confident is as lightweight as it can be.</span><font c=
olor=3D"#000000" face=3D"Times New Roman" size=3D"3">

</font><p style=3D"margin: 0in 0in 0pt; line-height: normal; vertical-align=
: baseline;"><span style=3D'color: rgb(34, 34, 34); font-family: "Arial","s=
ans-serif"; font-size: 10pt; mso-fareast-font-family: "Times New Roman";'>&=
nbsp;</span></p><font color=3D"#000000" face=3D"Times New Roman" size=3D"3"=
>

</font><p style=3D"margin: 0in 0in 0pt 0.5in; line-height: normal; vertical=
-align: baseline;"><span style=3D'color: rgb(34, 34, 34); font-family: "Ari=
al","sans-serif"; font-size: 10pt; mso-fareast-font-family: "Times New Roma=
n";'>I started the design on N4134, with an attempt
to generalize the lambda. I called it lambda*. This lambda*=E2=80=99s closu=
re would
contain not only the capture, but also a room for all the locals in the bod=
y of
operator(). Essentially, same idea as N4244. However, when applying to
different patterns, it seemed to me that nearly always it needed to be wrap=
ped
in some kind of helper function that frequently need to allocate the memory=
 for
lambda somewhere to give it a stable location.</span></p><font color=3D"#00=
0000" face=3D"Times New Roman" size=3D"3">

</font><p style=3D"margin: 0in 0in 0pt 0.5in; line-height: normal; vertical=
-align: baseline;"><span style=3D'color: rgb(34, 34, 34); font-family: "Ari=
al","sans-serif"; font-size: 10pt; mso-fareast-font-family: "Times New Roma=
n";'>You can think of N4134 is a syntactic sugar wrapper
around a lambda, such as in N4244.<br>
<br>
In case, where lifetime of a coroutine is fully contained in the lifetime o=
f a
calling function, heap allocation is elided and it becomes exactly the lamb=
da*.<br>
<br>
I did not find a case where I needed to expose lambda* itself. </span></p><=
font color=3D"#000000" face=3D"Times New Roman" size=3D"3">

</font><p style=3D"margin: 0in 0in 0pt; line-height: normal; vertical-align=
: baseline;"><span style=3D'color: rgb(34, 34, 34); font-family: "Arial","s=
ans-serif"; font-size: 10pt; mso-fareast-font-family: "Times New Roman";'>&=
nbsp;</span></p><font color=3D"#000000" face=3D"Times New Roman" size=3D"3"=
>
</font><font color=3D"#000000" face=3D"Times New Roman" size=3D"3">

</font><p style=3D"margin: 0in 0in 0pt; line-height: normal; vertical-align=
: baseline;"><span style=3D'color: rgb(34, 34, 34); font-family: "Arial","s=
ans-serif"; font-size: 10pt; mso-fareast-font-family: "Times New Roman";'>t=
emplate&lt;class
T&gt;</span></p><font color=3D"#000000" face=3D"Times New Roman" size=3D"3"=
>

</font><p style=3D"margin: 0in 0in 0pt; line-height: normal; vertical-align=
: baseline;"><span style=3D'color: rgb(34, 34, 34); font-family: "Arial","s=
ans-serif"; font-size: 10pt; mso-fareast-font-family: "Times New Roman";'>a=
sync_generator&lt;pair&lt;T,
system_clock::time_point&gt;&gt;</span></p><font color=3D"#000000" face=3D"=
Times New Roman" size=3D"3">

</font><p style=3D"margin: 0in 0in 0pt; line-height: normal; vertical-align=
: baseline;"><span style=3D'color: rgb(34, 34, 34); font-family: "Arial","s=
ans-serif"; font-size: 10pt; mso-fareast-font-family: "Times New Roman";'>T=
imestamp(async_read_stream&lt;T&gt;
S)&nbsp;</span></p><font color=3D"#000000" face=3D"Times New Roman" size=3D=
"3">

</font><p style=3D"margin: 0in 0in 0pt; line-height: normal; vertical-align=
: baseline;"><span style=3D'color: rgb(34, 34, 34); font-family: "Arial","s=
ans-serif"; font-size: 10pt; mso-fareast-font-family: "Times New Roman";'>{=
</span></p><font color=3D"#000000" face=3D"Times New Roman" size=3D"3">

</font><p style=3D"margin: 0in 0in 0pt; line-height: normal; vertical-align=
: baseline;"><span style=3D'color: rgb(34, 34, 34); font-family: "Arial","s=
ans-serif"; font-size: 10pt; mso-fareast-font-family: "Times New Roman";'>&=
nbsp; &nbsp; for
await(v: S) yield {v, system_clock::now()};</span></p><font color=3D"#00000=
0" face=3D"Times New Roman" size=3D"3">

</font><div style=3D"margin: 0in 0in 0pt; line-height: normal; vertical-ali=
gn: baseline;"><span style=3D'color: rgb(34, 34, 34); font-family: "Arial",=
"sans-serif"; font-size: 10pt; mso-fareast-font-family: "Times New Roman";'=
>}</span></div><div style=3D"margin: 0in 0in 0pt; line-height: normal; vert=
ical-align: baseline;"><span style=3D'color: rgb(34, 34, 34); font-family: =
"Arial","sans-serif"; font-size: 10pt; mso-fareast-font-family: "Times New =
Roman";'>the body states very succinctly what it is doing. For every v rece=
ived from S yield a pair of values v received and a timestamp when it was r=
eceived. I can also rewrite it as:</span></div><div style=3D"margin: 0in 0i=
n 0pt; line-height: normal; vertical-align: baseline;"><span style=3D'color=
: rgb(34, 34, 34); font-family: "Arial","sans-serif"; font-size: 10pt; mso-=
fareast-font-family: "Times New Roman";'><br></span></div><div style=3D"mar=
gin: 0in 0in 0pt; line-height: normal; vertical-align: baseline;"><span sty=
le=3D'color: rgb(34, 34, 34); font-family: "Arial","sans-serif"; font-size:=
 10pt; mso-fareast-font-family: "Times New Roman";'><p style=3D"margin: 0in=
 0in 0pt; line-height: normal; vertical-align: baseline;"><span style=3D'co=
lor: rgb(34, 34, 34); font-family: "Arial","sans-serif"; font-size: 10pt; m=
so-fareast-font-family: "Times New Roman";'>auto Timestamp(async_read_strea=
m&lt;T&gt; S)&nbsp; </span><span style=3D'color: rgb(34, 34, 34); font-fami=
ly: "Arial","sans-serif"; font-size: 10pt; mso-fareast-font-family: "Times =
New Roman";'>{</span></p><font color=3D"#000000" face=3D"Times New Roman" s=
ize=3D"3"></font><p style=3D"margin: 0in 0in 0pt; line-height: normal; vert=
ical-align: baseline;"><span style=3D'color: rgb(34, 34, 34); font-family: =
"Arial","sans-serif"; font-size: 10pt; mso-fareast-font-family: "Times New =
Roman";'>&nbsp; &nbsp; for await(v: S) yield make_pair(v, system_clock::now=
());</span></p><font color=3D"#000000" face=3D"Times New Roman" size=3D"3">=
</font><div style=3D"margin: 0in 0in 0pt; line-height: normal; vertical-ali=
gn: baseline;"><span style=3D'color: rgb(34, 34, 34); font-family: "Arial",=
"sans-serif"; font-size: 10pt; mso-fareast-font-family: "Times New Roman";'=
>}</span></div><div style=3D"margin: 0in 0in 0pt; line-height: normal; vert=
ical-align: baseline;"><span style=3D'color: rgb(34, 34, 34); font-family: =
"Arial","sans-serif"; font-size: 10pt; mso-fareast-font-family: "Times New =
Roman";'><br></span></div><div style=3D"margin: 0in 0in 0pt; line-height: n=
ormal; vertical-align: baseline;"><span style=3D'color: rgb(34, 34, 34); fo=
nt-family: "Arial","sans-serif"; font-size: 10pt; mso-fareast-font-family: =
"Times New Roman";'>If you want to know what happens "under the hood" for a=
wait-for a yield, look for the details in N4134.</span></div></span></div><=
font color=3D"#000000" face=3D"Times New Roman" size=3D"3">

</font><p style=3D"margin: 0in 0in 0pt; line-height: normal; vertical-align=
: baseline;"><span style=3D'color: rgb(34, 34, 34); font-family: "Arial","s=
ans-serif"; font-size: 10pt; mso-fareast-font-family: "Times New Roman";'>&=
nbsp;</span></p><font color=3D"#000000" face=3D"Times New Roman" size=3D"3"=
>

</font><p style=3D"margin: 0in 0in 0pt; line-height: normal; vertical-align=
: baseline;"><span style=3D'color: rgb(34, 34, 34); font-family: "Arial","s=
ans-serif"; font-size: 10pt; mso-fareast-font-family: "Times New Roman";'>O=
n page 16 of N4134,
you can see the expansion of await-for which is nearly the same as range-ba=
sed
for with the exception that every =E2=80=9Casyn pull=E2=80=9D operation is =
annotated with =E2=80=9Cawait=E2=80=9D</span></p><font color=3D"#000000" fa=
ce=3D"Times New Roman" size=3D"3">

</font><p style=3D"margin: 0in 0in 0pt; line-height: normal; vertical-align=
: baseline;"><span style=3D'color: rgb(34, 34, 34); font-family: "Arial","s=
ans-serif"; font-size: 10pt; mso-fareast-font-family: "Times New Roman";'>&=
nbsp;</span></p><font color=3D"#000000" face=3D"Times New Roman" size=3D"3"=
>

</font><p style=3D"margin: 0in 0in 0pt; line-height: normal; mso-layout-gri=
d-align: none;"><b><span style=3D'color: black; font-family: "Consolas,Bold=
","sans-serif"; font-size: 9.5pt;'>for await </span></b><span style=3D"colo=
r: black; font-family: Consolas; font-size: 9.5pt;">( for-range-declaration=
 : </span><i><span style=3D'color: black; font-family: "Consolas,Italic","s=
ans-serif"; font-size: 9.5pt;'>expression </span></i><span style=3D"color: =
black; font-family: Consolas; font-size: 9.5pt;">) statement</span></p><fon=
t color=3D"#000000" face=3D"Times New Roman" size=3D"3">

</font><p style=3D"margin: 0in 0in 0pt; line-height: normal; mso-layout-gri=
d-align: none;"><span style=3D"color: black; mso-bidi-font-family: Calibri;=
 mso-ascii-font-family: Calibri; mso-hansi-font-family: Calibri;"><font fac=
e=3D"Calibri" size=3D"3">&nbsp;</font></span></p><font color=3D"#000000" fa=
ce=3D"Times New Roman" size=3D"3">

</font><p style=3D"margin: 0in 0in 0pt; line-height: normal; mso-layout-gri=
d-align: none;"><span style=3D"color: black; mso-bidi-font-family: Calibri;=
 mso-ascii-font-family: Calibri; mso-hansi-font-family: Calibri;"><font siz=
e=3D"3"><font face=3D"Calibri"><span style=3D"mso-spacerun: yes;">&nbsp;&nb=
sp;&nbsp;&nbsp; </span>is equivalent </font></font></span><span style=3D"co=
lor: black; font-family: Consolas; font-size: 9.5pt;">to</span></p><font co=
lor=3D"#000000" face=3D"Times New Roman" size=3D"3">

</font><p style=3D"margin: 0in 0in 0pt; line-height: normal; mso-layout-gri=
d-align: none;"><span style=3D"color: black; font-family: Consolas; font-si=
ze: 9.5pt;">&nbsp;</span></p><font color=3D"#000000" face=3D"Times New Roma=
n" size=3D"3">

</font><p style=3D"margin: 0in 0in 0pt; line-height: normal; mso-layout-gri=
d-align: none;"><span style=3D"color: black; font-family: Consolas; font-si=
ze: 9.5pt;">{</span></p><font color=3D"#000000" face=3D"Times New Roman" si=
ze=3D"3">

</font><p style=3D"margin: 0in 0in 0pt 0.5in; line-height: normal; mso-layo=
ut-grid-align: none;"><b><span style=3D'color: black; font-family: "Consola=
s,Bold","sans-serif"; font-size: 9.5pt;'>auto </span></b><span style=3D"col=
or: black; font-family: Consolas; font-size: 9.5pt;">&amp;&amp; __range =3D=
 </span><i><span style=3D'color: black; font-family: "Consolas,Italic","san=
s-serif"; font-size: 9.5pt;'>expression</span></i><span style=3D"color: bla=
ck; font-family: Consolas; font-size: 9.5pt;">;</span></p><font color=3D"#0=
00000" face=3D"Times New Roman" size=3D"3">

</font><p style=3D"margin: 0in 0in 0pt 0.5in; line-height: normal; mso-layo=
ut-grid-align: none;"><b><span style=3D'color: black; font-family: "Consola=
s,Bold","sans-serif"; font-size: 9.5pt;'>for </span></b><span style=3D"colo=
r: black; font-family: Consolas; font-size: 9.5pt;">( </span><b><span style=
=3D'color: black; font-family: "Consolas,Bold","sans-serif"; font-size: 9.5=
pt;'>auto </span></b><span style=3D"color: black; font-family: Consolas; fo=
nt-size: 9.5pt;">__begin =3D </span><b><span style=3D'color: black; font-fa=
mily: "Consolas,Bold","sans-serif"; font-size: 9.5pt;'>await </span></b><sp=
an style=3D"color: black; font-family: Consolas; font-size: 9.5pt;">begin-e=
xpr,</span></p><font color=3D"#000000" face=3D"Times New Roman" size=3D"3">

</font><p style=3D"margin: 0in 0in 0pt 1.5in; line-height: normal; mso-layo=
ut-grid-align: none;"><span style=3D"color: black; font-family: Consolas; f=
ont-size: 9.5pt;">__end =3D end-expr;</span></p><font color=3D"#000000" fac=
e=3D"Times New Roman" size=3D"3">

</font><p style=3D"margin: 0in 0in 0pt 1.5in; line-height: normal; mso-layo=
ut-grid-align: none;"><span style=3D"color: black; font-family: Consolas; f=
ont-size: 9.5pt;">__begin !=3D __end;</span></p><font color=3D"#000000" fac=
e=3D"Times New Roman" size=3D"3">

</font><p style=3D"margin: 0in 0in 0pt 0.5in; line-height: normal; text-ind=
ent: 0.5in; mso-layout-grid-align: none;"><b><span style=3D'color: black; f=
ont-family: "Consolas,Bold","sans-serif"; font-size: 9.5pt;'>await </span><=
/b><span style=3D"color: black; font-family: Consolas; font-size: 9.5pt;">+=
+__begin )</span></p><font color=3D"#000000" face=3D"Times New Roman" size=
=3D"3">

</font><p style=3D"margin: 0in 0in 0pt 0.5in; line-height: normal; mso-layo=
ut-grid-align: none;"><span style=3D"color: black; font-family: Consolas; f=
ont-size: 9.5pt;">{</span></p><font color=3D"#000000" face=3D"Times New Rom=
an" size=3D"3">

</font><p style=3D"margin: 0in 0in 0pt 0.5in; line-height: normal; mso-layo=
ut-grid-align: none;"><i><span style=3D'color: black; font-family: "Consola=
s,Italic","sans-serif"; font-size: 9.5pt;'>for-range-declaration </span></i=
><span style=3D"color: black; font-family: Consolas; font-size: 9.5pt;">=3D=
 *__begin;</span></p><font color=3D"#000000" face=3D"Times New Roman" size=
=3D"3">

</font><p style=3D"margin: 0in 0in 0pt 0.5in; line-height: normal; mso-layo=
ut-grid-align: none;"><span style=3D"color: black; font-family: Consolas; f=
ont-size: 9.5pt;">statement</span></p><font color=3D"#000000" face=3D"Times=
 New Roman" size=3D"3">

</font><p style=3D"margin: 0in 0in 0pt 0.5in; line-height: normal; mso-layo=
ut-grid-align: none;"><span style=3D"color: black; font-family: Consolas; f=
ont-size: 9.5pt;">}</span></p><font color=3D"#000000" face=3D"Times New Rom=
an" size=3D"3">

</font><p style=3D"margin: 0in 0in 0pt; line-height: normal; vertical-align=
: baseline;"><span style=3D"color: black; font-family: Consolas; font-size:=
 9.5pt;">}</span></p><font color=3D"#000000" face=3D"Times New Roman" size=
=3D"3">

</font><div style=3D"margin: 0in 0in 0pt; line-height: normal; vertical-ali=
gn: baseline;"><span style=3D'color: rgb(34, 34, 34); font-family: "Arial",=
"sans-serif"; font-size: 10pt; mso-fareast-font-family: "Times New Roman";'=
><br></span></div><div style=3D"margin: 0in 0in 0pt; line-height: normal; v=
ertical-align: baseline;"><span style=3D'color: rgb(34, 34, 34); font-famil=
y: "Arial","sans-serif"; font-size: 10pt; mso-fareast-font-family: "Times N=
ew Roman";'>On page 15, there is a decription of what happens for yield:</s=
pan></div><div style=3D"margin: 0in 0in 0pt; line-height: normal; vertical-=
align: baseline;"><span style=3D'color: rgb(34, 34, 34); font-family: "Aria=
l","sans-serif"; font-size: 10pt; mso-fareast-font-family: "Times New Roman=
";'><font face=3D"Calibri" size=3D"3"><font face=3D"Calibri" size=3D"3"><p =
align=3D"LEFT">A yield statement is a statement of form:</p>
</font></font><b><font face=3D"Calibri,Bold" size=3D"3"><font face=3D"Calib=
ri,Bold" size=3D"3"></font></font></b><font face=3D"Calibri,Bold" size=3D"3=
"><font face=3D"Calibri,Bold" size=3D"3"></font></font><p align=3D"LEFT"><f=
ont face=3D"Calibri,Bold" size=3D"3"><font face=3D"Calibri,Bold" size=3D"3"=
><b>yield </b></font></font><i><font face=3D"Calibri,Italic" size=3D"3"><fo=
nt face=3D"Calibri,Italic" size=3D"3">expression</font></font></i><font fac=
e=3D"Calibri" size=3D"3"><font face=3D"Calibri" size=3D"3">;</font></font><=
/p><font face=3D"Calibri" size=3D"3"><font face=3D"Calibri" size=3D"3">
<p align=3D"LEFT">or</p>
</font></font><b><font face=3D"Calibri,Bold" size=3D"3"><font face=3D"Calib=
ri,Bold" size=3D"3"></font></font></b><font face=3D"Calibri,Bold" size=3D"3=
"><font face=3D"Calibri,Bold" size=3D"3"></font></font><p align=3D"LEFT"><f=
ont face=3D"Calibri,Bold" size=3D"3"><font face=3D"Calibri,Bold" size=3D"3"=
><b>yield </b></font></font><i><font face=3D"Calibri,Italic" size=3D"3"><fo=
nt face=3D"Calibri,Italic" size=3D"3">braced-init-list</font></font></i><fo=
nt face=3D"Calibri" size=3D"3"><font face=3D"Calibri" size=3D"3">;</font></=
font></p><font face=3D"Calibri" size=3D"3"><font face=3D"Calibri" size=3D"3=
">
</font></font><font color=3D"#0000ff" face=3D"Consolas" size=3D"2"><font co=
lor=3D"#0000ff" face=3D"Consolas" size=3D"2"><font color=3D"#0000ff" face=
=3D"Consolas" size=3D"2"></font></font></font><p align=3D"LEFT"><font color=
=3D"#0000ff" face=3D"Consolas" size=3D"2"><font color=3D"#0000ff" face=3D"C=
onsolas" size=3D"2"><font color=3D"#0000ff" face=3D"Consolas" size=3D"2">yi=
eld </font></font></font><font face=3D"Calibri" size=3D"3"><font face=3D"Ca=
libri" size=3D"3">&lt;something&gt;; is equivalent to</font></font></p><fon=
t face=3D"Calibri" size=3D"3"><font face=3D"Calibri" size=3D"3">
</font></font><p align=3D"LEFT"><font face=3D"Calibri" size=3D"3"><font fac=
e=3D"Calibri" size=3D"3">(void)(</font></font><font color=3D"#0000ff" face=
=3D"Consolas" size=3D"2"><font color=3D"#0000ff" face=3D"Consolas" size=3D"=
2"><font color=3D"#0000ff" face=3D"Consolas" size=3D"2">await </font></font=
></font><font color=3D"#2b92b0" face=3D"Consolas" size=3D"2"><font color=3D=
"#2b92b0" face=3D"Consolas" size=3D"2"><font color=3D"#2b92b0" face=3D"Cons=
olas" size=3D"2">&lt;Promise&gt;.yield_value</font></font></font><font face=
=3D"Calibri" size=3D"3"><font face=3D"Calibri" size=3D"3">(&lt;something&gt=
;))</font></font></p><font face=3D"Calibri" size=3D"3"><font face=3D"Calibr=
i" size=3D"3">
<p>Where a &lt;Promise&gt; refers to the coroutine promise of the enclosing=
 resumable function.</p></font></font></span></div><font color=3D"#000000" =
face=3D"Times New Roman" size=3D"3">

</font><p style=3D"margin: 0in 0in 0pt; line-height: normal; vertical-align=
: baseline;"><span style=3D'color: rgb(34, 34, 34); font-family: "Arial","s=
ans-serif"; font-size: 10pt; mso-fareast-font-family: "Times New Roman";'><=
br></span></p><font color=3D"#000000" face=3D"Times New Roman" size=3D"3">

</font><p style=3D"margin: 0in 0in 0pt; line-height: normal; vertical-align=
: baseline;"><span style=3D'color: rgb(34, 34, 34); font-family: "Arial","s=
ans-serif"; font-size: 10pt; mso-fareast-font-family: "Times New Roman";'>&=
gt;&gt; I can't figure out how
this is implemented. Sorry if I don't fully understand things yet.</span></=
p><font color=3D"#000000" face=3D"Times New Roman" size=3D"3">

</font><div style=3D"margin: 0in 0in 0pt; line-height: normal; vertical-ali=
gn: baseline;"><span style=3D'color: rgb(34, 34, 34); font-family: "Arial",=
"sans-serif"; font-size: 10pt; mso-fareast-font-family: "Times New Roman";'=
><br></span></div><div style=3D"margin: 0in 0in 0pt; line-height: normal; v=
ertical-align: baseline;"><span style=3D'color: rgb(34, 34, 34); font-famil=
y: "Arial","sans-serif"; font-size: 10pt; mso-fareast-font-family: "Times N=
ew Roman";'>Think of N4134 as
range-based for on steroids. It is mostly syntactic sugar and efficient
suspend and resume giving the library designer to imbue coroutines with
meaning. </span></div><font color=3D"#000000" face=3D"Times New Roman" size=
=3D"3">

</font><p style=3D"margin: 0in 0in 0pt; line-height: normal; vertical-align=
: baseline;"><span style=3D'color: rgb(34, 34, 34); font-family: "Arial","s=
ans-serif"; font-size: 10pt; mso-fareast-font-family: "Times New Roman";'>&=
nbsp;</span></p><font color=3D"#000000" face=3D"Times New Roman" size=3D"3"=
>

</font><p style=3D"margin: 0in 0in 0pt; line-height: normal; vertical-align=
: baseline;"><span style=3D'color: rgb(34, 34, 34); font-family: "Arial","s=
ans-serif"; font-size: 10pt; mso-fareast-font-family: "Times New Roman";'>F=
ull implementation of
generator is listed in Appendix A of N4134, also, you can find there adapte=
rs
to boost::futures and other things.</span></p><font color=3D"#000000" face=
=3D"Times New Roman" size=3D"3">

</font><p style=3D"margin: 0in 0in 0pt; line-height: normal; vertical-align=
: baseline;"><span style=3D'color: rgb(34, 34, 34); font-family: "Arial","s=
ans-serif"; font-size: 10pt; mso-fareast-font-family: "Times New Roman";'>&=
nbsp;</span></p><font color=3D"#000000" face=3D"Times New Roman" size=3D"3"=
>

</font><p style=3D"margin: 0in 0in 8pt;"><span style=3D'color: rgb(34, 34, =
34); line-height: 107%; font-family: "Arial","sans-serif"; font-size: 10pt;=
'>Are both implementations equivalente in
expressive power?<br>
<br>
In my, biased, </span><span style=3D"color: rgb(34, 34, 34); line-height: 1=
07%; font-family: Wingdings; font-size: 10pt; mso-bidi-font-family: Arial; =
mso-ascii-font-family: Arial; mso-hansi-font-family: Arial; mso-char-type: =
symbol; mso-symbol-font-family: Wingdings;"><span style=3D"mso-char-type: s=
ymbol; mso-symbol-font-family: Wingdings;">J</span></span><span style=3D'co=
lor: rgb(34, 34, 34); line-height: 107%; font-family: "Arial","sans-serif";=
 font-size: 10pt;'> view. N4134 can solve any problem that N4244 can with s=
horter
code and the same or better performance. The opposite is not true.</span></=
p><font color=3D"#000000" face=3D"Times New Roman" size=3D"3">

</font><p style=3D"margin: 0in 0in 8pt;"><span style=3D'color: rgb(34, 34, =
34); line-height: 107%; font-family: "Arial","sans-serif"; font-size: 10pt;=
'>Also, N4134 machinery is applicable to
other problems domain, besides coroutine and async. For example, Geoffrey R=
omer
noticed that he can adapt await to simplify working with monadic classes su=
ch
as optional.</span></p><font color=3D"#000000" face=3D"Times New Roman" siz=
e=3D"3">

</font><p style=3D"margin: 0in 0in 8pt;"><span style=3D'color: rgb(34, 34, =
34); line-height: 107%; font-family: "Arial","sans-serif"; font-size: 10pt;=
'>&nbsp;</span></p><font color=3D"#000000" face=3D"Times New Roman" size=3D=
"3">

</font><p style=3D"margin: 0in 0in 8pt;"><span style=3D"background: white; =
color: black; line-height: 107%; font-family: Consolas; font-size: 9.5pt; m=
so-highlight: white;">optional&lt;Foo&gt; FooSource();<br>
optional&lt;Bar&gt; BarFromFoo(</span><span style=3D"background: white; col=
or: blue; line-height: 107%; font-family: Consolas; font-size: 9.5pt; mso-h=
ighlight: white;">const</span><span style=3D"background: white; color: blac=
k; line-height: 107%; font-family: Consolas; font-size: 9.5pt; mso-highligh=
t: white;"> Foo&amp;);<br>
~~~~~~~~~~~~~~~~~~~~~~~~~~ with await ~~~~~~~~~~<br>
optional&lt;Baz&gt; f() {<br>
&nbsp; Bar bar =3D await BarFromFoo(await FooSource());<br>
&nbsp; Baz baz;<br>
&nbsp; </span><span style=3D"background: white; color: green; line-height: =
107%; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">// Co=
mpute baz from bar</span><span style=3D"background: white; color: black; li=
ne-height: 107%; font-family: Consolas; font-size: 9.5pt; mso-highlight: wh=
ite;"><br>
&nbsp; </span><span style=3D"background: white; color: blue; line-height: 1=
07%; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">return=
</span><span style=3D"background: white; color: black; line-height: 107%; f=
ont-family: Consolas; font-size: 9.5pt; mso-highlight: white;"> baz;<br>
}<br>
~~~~~~~~~~~~~~~~~~~~~~~~~~~without await ~~~~~~~~<br>
optional&lt;Baz&gt; f() {<br>
<span style=3D"mso-spacerun: yes;">&nbsp; </span>optional&lt;Foo&gt; foo =
=3D FooSource();</span></p><font color=3D"#000000" face=3D"Times New Roman"=
 size=3D"3">

</font><p style=3D"margin: 0in 0in 8pt;"><span style=3D"background: white; =
color: black; line-height: 107%; font-family: Consolas; font-size: 9.5pt; m=
so-highlight: white;">&nbsp; </span><span style=3D"background: white; color=
: blue; line-height: 107%; font-family: Consolas; font-size: 9.5pt; mso-hig=
hlight: white;">if</span><span style=3D"background: white; color: black; li=
ne-height: 107%; font-family: Consolas; font-size: 9.5pt; mso-highlight: wh=
ite;"> (!foo) {</span></p><font color=3D"#000000" face=3D"Times New Roman" =
size=3D"3">

</font><p style=3D"margin: 0in 0in 8pt;"><span style=3D"background: white; =
color: black; line-height: 107%; font-family: Consolas; font-size: 9.5pt; m=
so-highlight: white;">&nbsp;&nbsp;&nbsp; </span><span style=3D"background: =
white; color: blue; line-height: 107%; font-family: Consolas; font-size: 9.=
5pt; mso-highlight: white;">return</span><span style=3D"background: white; =
color: black; line-height: 107%; font-family: Consolas; font-size: 9.5pt; m=
so-highlight: white;"> nullopt;</span></p><font color=3D"#000000" face=3D"T=
imes New Roman" size=3D"3">

</font><p style=3D"margin: 0in 0in 8pt;"><span style=3D"background: white; =
color: black; line-height: 107%; font-family: Consolas; font-size: 9.5pt; m=
so-highlight: white;">&nbsp; }</span></p><font color=3D"#000000" face=3D"Ti=
mes New Roman" size=3D"3">

</font><p style=3D"margin: 0in 0in 8pt;"><span style=3D"background: white; =
color: black; line-height: 107%; font-family: Consolas; font-size: 9.5pt; m=
so-highlight: white;">&nbsp; optional&lt;Bar&gt; bar =3D BarFromFoo(*foo);<=
/span></p><font color=3D"#000000" face=3D"Times New Roman" size=3D"3">

</font><p style=3D"margin: 0in 0in 8pt;"><span style=3D"background: white; =
color: black; line-height: 107%; font-family: Consolas; font-size: 9.5pt; m=
so-highlight: white;">&nbsp; </span><span style=3D"background: white; color=
: blue; line-height: 107%; font-family: Consolas; font-size: 9.5pt; mso-hig=
hlight: white;">if</span><span style=3D"background: white; color: black; li=
ne-height: 107%; font-family: Consolas; font-size: 9.5pt; mso-highlight: wh=
ite;"> (!bar) {</span></p><font color=3D"#000000" face=3D"Times New Roman" =
size=3D"3">

</font><p style=3D"margin: 0in 0in 8pt;"><span style=3D"background: white; =
color: black; line-height: 107%; font-family: Consolas; font-size: 9.5pt; m=
so-highlight: white;">&nbsp;&nbsp;&nbsp; </span><span style=3D"background: =
white; color: blue; line-height: 107%; font-family: Consolas; font-size: 9.=
5pt; mso-highlight: white;">return</span><span style=3D"background: white; =
color: black; line-height: 107%; font-family: Consolas; font-size: 9.5pt; m=
so-highlight: white;"> nullopt;</span></p><font color=3D"#000000" face=3D"T=
imes New Roman" size=3D"3">

</font><p style=3D"margin: 0in 0in 8pt;"><span style=3D"background: white; =
color: black; line-height: 107%; font-family: Consolas; font-size: 9.5pt; m=
so-highlight: white;">&nbsp; }</span></p><font color=3D"#000000" face=3D"Ti=
mes New Roman" size=3D"3">

</font><p style=3D"margin: 0in 0in 8pt;"><span style=3D"background: white; =
color: black; line-height: 107%; font-family: Consolas; font-size: 9.5pt; m=
so-highlight: white;">&nbsp; Baz baz;</span></p><font color=3D"#000000" fac=
e=3D"Times New Roman" size=3D"3">

</font><p style=3D"margin: 0in 0in 8pt;"><span style=3D"background: white; =
color: black; line-height: 107%; font-family: Consolas; font-size: 9.5pt; m=
so-highlight: white;">&nbsp; </span><span style=3D"background: white; color=
: green; line-height: 107%; font-family: Consolas; font-size: 9.5pt; mso-hi=
ghlight: white;">// Compute baz from
*bar</span></p><font color=3D"#000000" face=3D"Times New Roman" size=3D"3">

</font><p style=3D"margin: 0in 0in 8pt;"><span style=3D"background: white; =
color: black; line-height: 107%; font-family: Consolas; font-size: 9.5pt; m=
so-highlight: white;">&nbsp; </span><span style=3D"background: white; color=
: blue; line-height: 107%; font-family: Consolas; font-size: 9.5pt; mso-hig=
hlight: white;">return</span><span style=3D"background: white; color: black=
; line-height: 107%; font-family: Consolas; font-size: 9.5pt; mso-highlight=
: white;"> baz;</span></p><font color=3D"#000000" face=3D"Times New Roman" =
size=3D"3">

</font><p style=3D"margin: 0in 0in 8pt;"><span style=3D"background: white; =
color: black; line-height: 107%; font-family: Consolas; font-size: 9.5pt; m=
so-highlight: white;">}</span></p><font color=3D"#000000" face=3D"Times New=
 Roman" size=3D"3">

</font><p style=3D"margin: 0in 0in 8pt;"><span style=3D"color: rgb(31, 73, =
125);"><font face=3D"Calibri" size=3D"3">~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~=
~~~~~~~~~</font></span></p><font color=3D"#000000" face=3D"Times New Roman"=
 size=3D"3">

</font><p style=3D"margin: 0in 0in 8pt;"><font color=3D"#000000" face=3D"Ca=
libri" size=3D"3">&nbsp;</font></p><font color=3D"#000000" face=3D"Times Ne=
w Roman" size=3D"3">

</font><br><br>On Saturday, October 25, 2014 2:58:08 AM UTC-7, Germ=C3=A1n =
Diago wrote:<blockquote class=3D"gmail_quote" style=3D"margin: 0px 0px 0px =
0.8ex; padding-left: 1ex; border-left-color: rgb(204, 204, 204); border-lef=
t-width: 1px; border-left-style: solid;"><div dir=3D"ltr">Forgot one questi=
on:<div><br></div><div>Are both implementations equivalente in expressive p=
ower?</div><div><br></div><div>Regards,</div><div>Germ=C3=A1n Diago G=C3=B3=
mez</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&quot; group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<br />
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/">http://groups.google.com/a/isocpp.org/group/std-proposals/<=
/a>.<br />

------=_Part_1911_1339040544.1414247414034--

.


Author: =?UTF-8?Q?Germ=C3=A1n_Diago?= <germandiago@gmail.com>
Date: Sat, 25 Oct 2014 23:57:31 -0700 (PDT)
Raw View
------=_Part_2251_1374314087.1414306651933
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

Hello again Gor,

I am trying to fully understand the proposal. One thing I don't fully=20
understand, again, when I compare to resumable lambdas, is the following:

"Compiler can construct a function that behaves as if the following code=20
was generated:"

auto mem =3D <allocate-frame>(sizeof(__Context) + <X>);
__Context * coro =3D nullptr;
....
"

The problem, about understanding what is going on, for me, is when you=20
invoke a function, like, let=C2=B4s say, a member function or a free functi=
on=20
that contains await/yield, etc. This will do some "magic", because the=20
state for the coroutine is kept somewhere, opaquely I guess. Correct me if=
=20
I am wrong.

In the resumable lambdas case, a lambda is an object, when you want a=20
resumable lambda you return it from a function. The state is all there,=20
absolutely all, there is no magic of any kind, as I understand it, except=
=20
generating the stack capture in the object, but I know it is inside.

I can reason about that as I reason with lambdas + captures. I fail to=20
reason correctly about this, maybe because I cannot get it yet.

Don't you think it would be more straightforward a model where lambdas are=
=20
first-class and keep all the state? I know you tried the lambda* thing=20
already, but I see an advantage in transparently thinking of a coroutine as=
=20
an object, and not as a member function that does some magic and actually=
=20
is an object, and that the compiler hides to me and I am not sure where it=
=20
lives in my program.


My point here is, again, understanding, not even efficiency anymore.


>

--=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_2251_1374314087.1414306651933
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr">Hello again Gor,<div><br></div><div>I am trying to fully u=
nderstand the proposal. One thing I don't fully understand, again, when I c=
ompare to resumable lambdas, is the following:</div><div><br></div><div><di=
v>"Compiler can construct a function that behaves as if the following code =
was generated:"</div><div><br></div><div><div>auto mem =3D &lt;allocate-fra=
me&gt;(sizeof(__Context) + &lt;X&gt;);</div></div><div><div>__Context * cor=
o =3D nullptr;</div></div><div>...</div><div>"</div><div><br></div><div>The=
 problem, about understanding what is going on, for me, is when you invoke =
a function, like, let=C2=B4s say, a member function or a free function that=
 contains await/yield, etc. This will do some "magic", because the state fo=
r the coroutine is kept somewhere, opaquely I guess. Correct me if I am wro=
ng.</div><div><br></div><div>In the resumable lambdas case, a lambda is an =
object, when you want a resumable lambda you return it from a function. The=
 state is all there, absolutely all, there is no magic of any kind, as I un=
derstand it, except generating the stack capture in the object, but I know =
it is inside.</div><div><br></div><div>I can reason about that as I reason =
with lambdas + captures. I fail to reason correctly about this, maybe becau=
se I cannot get it yet.</div><div><br></div><div>Don't you think it would b=
e more straightforward a model where lambdas are first-class and keep all t=
he state? I know you tried the lambda* thing already, but I see an advantag=
e in transparently thinking of a coroutine as an object, and not as a membe=
r function that does some magic and actually is an object, and that the com=
piler hides to me and I am not sure where it lives in my program.</div><div=
><br></div><div><br></div><div>My point here is, again, understanding, not =
even efficiency anymore.</div><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"><div><br></div></div></blockquote></div></div>

<p></p>

-- <br />
<br />
--- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals&quot; group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<br />
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/">http://groups.google.com/a/isocpp.org/group/std-proposals/<=
/a>.<br />

------=_Part_2251_1374314087.1414306651933--

.


Author: Gor Nishanov <gornishanov@gmail.com>
Date: Sun, 26 Oct 2014 11:10:06 -0700 (PDT)
Raw View
------=_Part_2548_356468595.1414347006042
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

Hi Germ=C3=A1n:


On Saturday, October 25, 2014 11:57:32 PM UTC-7, Germ=C3=A1n Diago wrote:

> Hello again Gor,
>
> I am trying to fully understand the proposal.=20
>

If you haven't looked at it yet, I can recommend watching=20
https://www.youtube.com/watch?v=3DKUhSjfSbINE
which walks through N4134.

You can find slides with more details at:

https://github.com/GorNishanov/await

If you can, look at PPTX version. Animations don't work in PDF version.
=20

> One thing I don't fully understand, again, when I compare to resumable=20
> lambdas, is the following:
>


=20

>
> "Compiler can construct a function that behaves as if the following code=
=20
> was generated:"
>
> auto mem =3D <allocate-frame>(sizeof(__Context) + <X>);
> __Context * coro =3D nullptr;
> ...
> "
>
> The problem, about understanding what is going on, for me, is when you=20
> invoke a function, like, let=C2=B4s say, a member function or a free func=
tion=20
> that contains await/yield, etc. This will do some "magic", because the=20
> state for the coroutine is kept somewhere, opaquely I guess.=20
>

Compare to a normal function. When you call a function, prolog allocates=20
room for local variables by adjusting stack pointer ( SUB RSP, X ). That is=
=20
a  very inexpensive way to allocation function frame, but it does not allow=
=20
to suspend it without suspending entire stack / thread.

In a coroutine, in a prolog, we allocate memory for the coroutine frame=20
using a library supplied allocator. It can be on the heap, on the stack,=20
in a global variable. Wherever the allocator place it.
=20

> Don't you think it would be more straightforward a model where lambdas ar=
e=20
> first-class and keep all the state?=20
>

I tried using them, but the code was too cumbersome and there were various=
=20
restrictions on what you can or cannot do in lambda* body. For example, you=
=20
cannot use std::mutex or std::atomic or any immobile type in a resumable=20
lambda (or lambda*), because that will make your lambda unmovable and=20
uncopyable. you can't do much with it.=20

So a wrapper around lambda*, a resumable function seemed like the right=20
answer.

Cheers,
Gor

--=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_2548_356468595.1414347006042
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><div>Hi Germ=C3=A1n:</div><div><br></div><div><br>On Satur=
day, October 25, 2014 11:57:32 PM UTC-7, Germ=C3=A1n Diago wrote:</div><blo=
ckquote class=3D"gmail_quote" style=3D"margin: 0px 0px 0px 0.8ex; padding-l=
eft: 1ex; border-left-color: rgb(204, 204, 204); border-left-width: 1px; bo=
rder-left-style: solid;"><div dir=3D"ltr">Hello again Gor,<div><br></div><d=
iv>I am trying to fully understand the proposal. </div></div></blockquote><=
div><br></div><div>If you haven't looked at it yet, I can recommend watchin=
g <a href=3D"https://www.youtube.com/watch?v=3DKUhSjfSbINE">https://www.you=
tube.com/watch?v=3DKUhSjfSbINE</a></div><div>which walks through N4134.</di=
v><div><br></div><div>You can find slides with more details at:</div><div><=
br></div><div><a href=3D"https://github.com/GorNishanov/await">https://gith=
ub.com/GorNishanov/await</a></div><div><br></div><div>If you can, look at P=
PTX version. Animations don't work in PDF version.</div><div>&nbsp;</div><b=
lockquote class=3D"gmail_quote" style=3D"margin: 0px 0px 0px 0.8ex; padding=
-left: 1ex; border-left-color: rgb(204, 204, 204); border-left-width: 1px; =
border-left-style: solid;"><div dir=3D"ltr"><div>One thing I don't fully un=
derstand, again, when I compare to resumable lambdas, is the following:<br>=
</div></div></blockquote><div><br></div><div><br></div><div>&nbsp;</div><bl=
ockquote class=3D"gmail_quote" style=3D"margin: 0px 0px 0px 0.8ex; padding-=
left: 1ex; border-left-color: rgb(204, 204, 204); border-left-width: 1px; b=
order-left-style: solid;"><div dir=3D"ltr"><div><br></div><div><div>"Compil=
er can construct a function that behaves as if the following code was gener=
ated:"</div><div><br></div><div><div>auto mem =3D &lt;allocate-frame&gt;(si=
zeof(__<wbr>Context) + &lt;X&gt;);</div></div><div><div>__Context * coro =
=3D nullptr;</div></div><div>...</div><div>"</div><div><br></div><div>The p=
roblem, about understanding what is going on, for me, is when you invoke a =
function, like, let=C2=B4s say, a member function or a free function that c=
ontains await/yield, etc. This will do some "magic", because the state for =
the coroutine is kept somewhere, opaquely I guess. </div></div></div></bloc=
kquote><div><br></div><div>Compare to a normal function. When you call a fu=
nction, prolog allocates room for local variables by adjusting stack pointe=
r ( SUB RSP, X ). That is a&nbsp; very inexpensive way to allocation functi=
on frame, but it does not allow to suspend it without suspending entire sta=
ck / thread.</div><div><br></div><div>In a coroutine, in a prolog, we alloc=
ate memory for the coroutine frame using a library supplied allocator. It c=
an be on the heap, on the stack, in&nbsp;a global variable. Wherever the al=
locator place it.</div><div>&nbsp;</div><blockquote class=3D"gmail_quote" s=
tyle=3D"margin: 0px 0px 0px 0.8ex; padding-left: 1ex; border-left-color: rg=
b(204, 204, 204); border-left-width: 1px; border-left-style: solid;"><div d=
ir=3D"ltr"><div><div>Don't you think it would be more straightforward a mod=
el where lambdas are first-class and keep all the state? <br></div></div></=
div></blockquote><div><br></div><div>I tried using them, but the code was t=
oo cumbersome and there were various restrictions on what you can or cannot=
 do in lambda* body. For example, you cannot use std::mutex or std::atomic =
or any immobile type in a resumable lambda (or lambda*), because that will =
make your lambda unmovable and uncopyable. you can't do much with it. </div=
><div><br></div><div>So a wrapper around lambda*, a resumable function seem=
ed like the right answer.</div><div><br></div><div>Cheers,</div><div>Gor<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&quot; group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<br />
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/">http://groups.google.com/a/isocpp.org/group/std-proposals/<=
/a>.<br />

------=_Part_2548_356468595.1414347006042--

.


Author: Jeremy Maitin-Shepard <jeremy@jeremyms.com>
Date: Sun, 26 Oct 2014 17:16:52 -0700 (PDT)
Raw View
------=_Part_288_126892131.1414369012227
Content-Type: text/plain; charset=UTF-8

On Sunday, October 26, 2014 11:10:06 AM UTC-7, Gor Nishanov wrote:
>
>
> I tried using them, but the code was too cumbersome and there were various
> restrictions on what you can or cannot do in lambda* body. For example, you
> cannot use std::mutex or std::atomic or any immobile type in a resumable
> lambda (or lambda*), because that will make your lambda unmovable and
> uncopyable. you can't do much with it.
>
>
It seems reasonable for the move and copy constructors to simply throw if
the current state is not movable/copyable.  (Chris suggested this as a
possibility as well.)  This wouldn't introduce any extra overhead since a
switch on the state is necessary anyway.  The most common and important
case would be moving from the initial state, which is always possible.

--

---
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_288_126892131.1414369012227
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr">On Sunday, October 26, 2014 11:10:06 AM UTC-7, Gor Nishano=
v 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"><br><=
div>I tried using them, but the code was too cumbersome and there were vari=
ous restrictions on what you can or cannot do in lambda* body. For example,=
 you cannot use std::mutex or std::atomic or any immobile type in a resumab=
le lambda (or lambda*), because that will make your lambda unmovable and un=
copyable. you can't do much with it. </div><div><br></div></div></blockquot=
e><div><br>It seems reasonable for the move and copy constructors to simply=
 throw if the current state is not movable/copyable.&nbsp; (Chris suggested=
 this as a possibility as well.)&nbsp; This wouldn't introduce any extra ov=
erhead since a switch on the state is necessary anyway.&nbsp; The most comm=
on and important case would be moving from the initial state, which is alwa=
ys possible. <br></div><br></div>

<p></p>

-- <br />
<br />
--- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals&quot; group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<br />
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/">http://groups.google.com/a/isocpp.org/group/std-proposals/<=
/a>.<br />

------=_Part_288_126892131.1414369012227--

.


Author: Gor Nishanov <gornishanov@gmail.com>
Date: Sun, 26 Oct 2014 18:09:59 -0700 (PDT)
Raw View
------=_Part_2767_608990395.1414372199763
Content-Type: text/plain; charset=UTF-8


On Sunday, October 26, 2014 5:16:52 PM UTC-7, Jeremy Maitin-Shepard wrote:

> the initial state, which is always possible.
>
>
Look at the countdown example on page 5 and add "std::mutex m;" inside of
the lambda, just before std::cout << ... Unless we change the definition of
the std::mutex to allow it to move, the code won't compile at all as it
would be impossible to generate the move constructor for the lambda.


--

---
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_2767_608990395.1414372199763
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><div><br>On Sunday, October 26, 2014 5:16:52 PM UTC-7, Jer=
emy Maitin-Shepard wrote:</div><blockquote class=3D"gmail_quote" style=3D"m=
argin: 0px 0px 0px 0.8ex; padding-left: 1ex; border-left-color: rgb(204, 20=
4, 204); border-left-width: 1px; border-left-style: solid;"><div dir=3D"ltr=
"><div>the initial state, which is always possible. <br></div><br></div></b=
lockquote><div><br></div><div>Look at the countdown example on page 5 and a=
dd "std::mutex m;"&nbsp;inside of the lambda, just before std::cout &lt;&lt=
; ... Unless we change the definition of the std::mutex to allow it to move=
,&nbsp;the code&nbsp;won't compile at all as it would be impossible to gene=
rate the move constructor for the lambda.</div><div><div><br></div><div><br=
></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&quot; group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<br />
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/">http://groups.google.com/a/isocpp.org/group/std-proposals/<=
/a>.<br />

------=_Part_2767_608990395.1414372199763--

.


Author: german.gomez@personifyinc.com
Date: Sun, 26 Oct 2014 23:07:05 -0700 (PDT)
Raw View
------=_Part_57_939632687.1414390025589
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable



On Saturday, October 25, 2014 10:43:14 AM UTC+7, Gor Nishanov wrote:
>
> Hi Germ=C3=A1n:
>
> You mentioned in a youtube comment that you are concerned about efficienc=
y=20
> of N4134 as compared to that of N4244. I am wondering if you have a=20
> particular example in mind. I am very interested in learning what do you=
=20
> think are the weak points of N4134 as compared to N4134.
>
>
Hello Gor,

I think I understand things a bit better than before, but not fully yet :D.=
=20
Coming back to the generator example, in the slides I see generator<int>=20
(slide 50 and following).

So the process I see in the slides is that there is a heap allocated=20
control block for the coroutine.

Comparing:

n4134 generator<int> fib(int n) { ...}

vs

n4244: auto fib =3D [](int n) resumable { ... }

n4134:

- Need heap alloc?
- In case I don't want heap alloc, do I need to customize alloc traits and=
=20
write more code?
+ Seems to fit in a bigger framework not only with generators very=20
transparently.

n4244:

+ Just function object sugar, really easy to understand, one of the most=20
appealing points IMHO.
+ I see obvious that I dont need a heap alloc, it is a function object.
+ I can reason how to copy/move a coroutine.
- When I want to do something like below (networking) things are a bit more=
=20
work to write.

My conclusion here is that n4244 is more efficient *by default*, because it=
=20
is not hiding that fact to me,
but correct me if I am wrong.=20

Your proposal seems to be able to write both examples,
the generator and the networking example, "uniformly",
making them look the same.=20

Example 2 (networking):

std::future<ptrdiff_t> tcp_reader(int total)=20

{

    char buf[64 * 1024];

    ptrdiff_t result =3D 0;

    auto conn =3D await Tcp::Connect("127.0.0.1", 1337);  =20

    do=20

    {

        auto bytesRead =3D await conn.Read(buf, sizeof(buf));

        total -=3D bytesRead;

        result +=3D std::count(buf, buf + bytesRead, 'c');

    }=20

    while (total > 0);

    return result;

}


Slide 9: where does the "coroutine frame" live? I cannot convince myself=20
this does not need runtime support of some kind,

because that state must be managed by someone.=20

Is this coroutine frame what can be controlled with the allocator (which=20
would be good).


A rough n4244 (pseudo boost.asio code omitting error_code) would be like=20
the following:


[](int total) resumable

{

                promise<ptrdiff_t> p;

                future<ptrdiff_t> res =3D p.get_future();

                char buf[64 * 1024];

                ptrdiff_t result =3D 0; =20

                auto conn =3D yield async_connect(..., *[]this);

                do {

                  auto bytes_read =3D yield conn.async_read(...., *[]this);

                  ...

                } while (total < 0);


                p.set_value(total);

                return res;

         }

}

I admit in n4134 it is a bit easier to write, but, if I am not wrong, not=
=20
without its costs.

n4134:

+ Easier to write.
+ Customizable to more than futures: good, but read below.
+/- At the same time, it is hiding me the promise parts of things in that=
=20
piece of code.
This is a double edged sword because it is convenient but makes reasoning=
=20
about what
happens harder, and possible defficiencies in performance hidden.
- Non/local state "somewhere". Where?

n4244:

- Harder to write. Though, I do know where all things are: inside the=20
object, because all the state is kept around.
+ Easy to reason about copy/move.
+ I dont need even to think of customizations, I could return anything:=20
just put it in the lambda body, it is gonna be saved
   in the object, locally. This eliminates the need for traits, it is just=
=20
a function object!
+ Local state is inside the object.

Biggest concerns from n4134:=20
=20
- heap allocations by default? Need customization point only for this?=20
Wouldn't be better to avoid heap in the first place? Is it=20
possible/feasible?
- copy/move a coroutine: I am not sure how it works, not all the state is=
=20
local. Easier for me to reason about n4244 in this sense.

P.S.: Feel free to criticize the most you can :D Sorry if there are some=20
assumptions/mistakes that don't hold true at some point.
This is my feedback as I understand both proposals, but I can never=20
understand them as deeply as the writers of both.

Regards,

Germ=C3=A1n Diago G=C3=B3mez


--=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_57_939632687.1414390025589
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><br><br>On Saturday, October 25, 2014 10:43:14 AM UTC+7, G=
or Nishanov wrote:<blockquote class=3D"gmail_quote" style=3D"margin: 0;marg=
in-left: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;"><div dir=3D"=
ltr"><div>Hi Germ=C3=A1n:</div><div><br></div><div>You mentioned in a youtu=
be comment that you are concerned about efficiency of N4134 as compared to =
that of N4244. I am wondering if you have&nbsp;a particular example in mind=
.. I am very interested in learning what do you think are&nbsp;the&nbsp;weak=
 points of N4134 as compared to N4134.</div><div><br></div></div></blockquo=
te><div><br></div><div>Hello Gor,</div><div><br></div><div>I think I unders=
tand things a bit better than before, but not fully yet :D.&nbsp;</div><div=
>Coming back to the generator example, in the slides I see generator&lt;int=
&gt; (slide 50 and following).</div><div><br></div><div>So the process I se=
e in the slides is that there is a heap allocated control block for the cor=
outine.</div><div><br></div><div>Comparing:</div><div><br></div><div>n4134 =
generator&lt;int&gt; fib(int n) { ...}</div><div><br></div><div>vs</div><di=
v><br></div><div>n4244: auto fib =3D [](int n) resumable { ... }</div><div>=
<br></div><div>n4134:</div><div><br></div><div>- Need heap alloc?</div><div=
>- In case I don't want heap alloc, do I need to customize alloc traits and=
 write more code?</div><div>+ Seems to fit in a bigger framework not only w=
ith generators very transparently.</div><div><br></div><div>n4244:</div><di=
v><br></div><div>+ Just function object sugar, really easy to understand, o=
ne of the most appealing points IMHO.</div><div>+ I see obvious that I dont=
 need a heap alloc, it is a function object.</div><div>+ I can reason how t=
o copy/move a coroutine.</div><div>- When I want to do something like below=
 (networking) things are a bit more work to write.</div><div><br></div><div=
>My conclusion here is that n4244 is more efficient *by default*, because i=
t is not hiding that fact to me,</div><div>but correct me if I am wrong.&nb=
sp;<br></div><div><br></div><div>Your proposal seems to be able to write bo=
th examples,<br></div><div>the generator and the networking example, "unifo=
rmly",</div><div>making them look the same.&nbsp;</div><div><br></div><div>=
Example 2 (networking):<br></div><div><br></div><div><p style=3D"margin-top=
: 0pt; margin-bottom: 0pt; margin-left: 0in; direction: ltr; unicode-bidi: =
embed; word-break: normal;"><span style=3D"font-size: 16pt; font-family: Co=
nsolas; color: black; background-image: initial; background-attachment: ini=
tial; background-size: initial; background-origin: initial; background-clip=
: initial; background-position: initial; background-repeat: initial;">std::=
</span><span style=3D"font-size: 16pt; font-family: Consolas; color: black;=
 background-image: initial; background-attachment: initial; background-size=
: initial; background-origin: initial; background-clip: initial; background=
-position: initial; background-repeat: initial;">future&lt;</span><span sty=
le=3D"font-size: 16pt; font-family: Consolas; color: blue; background-image=
: initial; background-attachment: initial; background-size: initial; backgr=
ound-origin: initial; background-clip: initial; background-position: initia=
l; background-repeat: initial;">ptrdiff_t</span><span style=3D"font-size: 1=
6pt; font-family: Consolas; color: black; background-image: initial; backgr=
ound-attachment: initial; background-size: initial; background-origin: init=
ial; background-clip: initial; background-position: initial; background-rep=
eat: initial;">&gt;
</span><span style=3D"font-size: 16pt; font-family: Consolas; color: black;=
 background-image: initial; background-attachment: initial; background-size=
: initial; background-origin: initial; background-clip: initial; background=
-position: initial; background-repeat: initial;">tcp_reader(</span><span st=
yle=3D"font-size: 16pt; font-family: Consolas; color: blue; background-imag=
e: initial; background-attachment: initial; background-size: initial; backg=
round-origin: initial; background-clip: initial; background-position: initi=
al; background-repeat: initial;">int</span><span style=3D"font-size: 16pt; =
font-family: Consolas; color: black; background-image: initial; background-=
attachment: initial; background-size: initial; background-origin: initial; =
background-clip: initial; background-position: initial; background-repeat: =
initial;">
total) </span></p>

<p style=3D"margin-top: 0pt; margin-bottom: 0pt; margin-left: 0in; directio=
n: ltr; unicode-bidi: embed; word-break: normal;"><span style=3D"font-size:=
 16pt; font-family: Consolas; color: black; background-image: initial; back=
ground-attachment: initial; background-size: initial; background-origin: in=
itial; background-clip: initial; background-position: initial; background-r=
epeat: initial;">{</span></p>

<p style=3D"margin-top: 0pt; margin-bottom: 0pt; margin-left: 0in; directio=
n: ltr; unicode-bidi: embed; word-break: normal;"><span style=3D"font-size:=
 16pt; font-family: Consolas; color: black; background-image: initial; back=
ground-attachment: initial; background-size: initial; background-origin: in=
itial; background-clip: initial; background-position: initial; background-r=
epeat: initial;">&nbsp;&nbsp;&nbsp; </span><span style=3D"font-size: 16pt; =
font-family: Consolas; color: blue; background-image: initial; background-a=
ttachment: initial; background-size: initial; background-origin: initial; b=
ackground-clip: initial; background-position: initial; background-repeat: i=
nitial;">char</span><span style=3D"font-size: 16pt; font-family: Consolas; =
color: black; background-image: initial; background-attachment: initial; ba=
ckground-size: initial; background-origin: initial; background-clip: initia=
l; background-position: initial; background-repeat: initial;">
</span><span style=3D"font-size: 16pt; font-family: Consolas; color: black;=
 background-image: initial; background-attachment: initial; background-size=
: initial; background-origin: initial; background-clip: initial; background=
-position: initial; background-repeat: initial;">buf</span><span style=3D"f=
ont-size: 16pt; font-family: Consolas; color: black; background-image: init=
ial; background-attachment: initial; background-size: initial; background-o=
rigin: initial; background-clip: initial; background-position: initial; bac=
kground-repeat: initial;">[64
* 1024</span><span style=3D"font-size: 16pt; font-family: Consolas; color: =
black; background-image: initial; background-attachment: initial; backgroun=
d-size: initial; background-origin: initial; background-clip: initial; back=
ground-position: initial; background-repeat: initial;">];</span></p>

<p style=3D"margin-top: 0pt; margin-bottom: 0pt; margin-left: 0in; directio=
n: ltr; unicode-bidi: embed; word-break: normal;"><span style=3D"font-size:=
 16pt; font-family: Consolas; color: black; background-image: initial; back=
ground-attachment: initial; background-size: initial; background-origin: in=
itial; background-clip: initial; background-position: initial; background-r=
epeat: initial;">&nbsp;&nbsp;&nbsp; </span><span style=3D"font-size: 16pt; =
font-family: Consolas; color: blue; background-image: initial; background-a=
ttachment: initial; background-size: initial; background-origin: initial; b=
ackground-clip: initial; background-position: initial; background-repeat: i=
nitial;">ptrdiff_t</span><span style=3D"font-size: 16pt; font-family: Conso=
las; color: black; background-image: initial; background-attachment: initia=
l; background-size: initial; background-origin: initial; background-clip: i=
nitial; background-position: initial; background-repeat: initial;">
result =3D 0;</span></p>

<p style=3D"margin-top: 0pt; margin-bottom: 0pt; margin-left: 0in; directio=
n: ltr; unicode-bidi: embed; word-break: normal;"></p>

<p style=3D"margin-top: 0pt; margin-bottom: 0pt; margin-left: 0in; directio=
n: ltr; unicode-bidi: embed; word-break: normal;"><span style=3D"font-size:=
 16pt; font-family: Consolas; color: black; background-image: initial; back=
ground-attachment: initial; background-size: initial; background-origin: in=
itial; background-clip: initial; background-position: initial; background-r=
epeat: initial;">&nbsp;&nbsp;&nbsp;
</span><span style=3D"font-size: 16pt; font-family: Consolas; color: blue; =
background-image: initial; background-attachment: initial; background-size:=
 initial; background-origin: initial; background-clip: initial; background-=
position: initial; background-repeat: initial;">auto</span><span style=3D"f=
ont-size: 16pt; font-family: Consolas; color: black; background-image: init=
ial; background-attachment: initial; background-size: initial; background-o=
rigin: initial; background-clip: initial; background-position: initial; bac=
kground-repeat: initial;">
conn =3D </span><span style=3D"font-size: 16pt; font-family: Consolas; colo=
r: blue; background-image: initial; background-attachment: initial; backgro=
und-size: initial; background-origin: initial; background-clip: initial; ba=
ckground-position: initial; background-repeat: initial;">await</span><span =
style=3D"font-size: 16pt; font-family: Consolas; color: black; background-i=
mage: initial; background-attachment: initial; background-size: initial; ba=
ckground-origin: initial; background-clip: initial; background-position: in=
itial; background-repeat: initial;">
Tcp</span><span style=3D"font-size: 16pt; font-family: Consolas; color: bla=
ck; background-image: initial; background-attachment: initial; background-s=
ize: initial; background-origin: initial; background-clip: initial; backgro=
und-position: initial; background-repeat: initial;">::Connect(</span><span =
style=3D"font-size: 16pt; font-family: Consolas; color: rgb(163, 21, 21); b=
ackground-image: initial; background-attachment: initial; background-size: =
initial; background-origin: initial; background-clip: initial; background-p=
osition: initial; background-repeat: initial;">"</span><span style=3D"font-=
size: 16pt; font-family: Consolas; color: rgb(163, 21, 21); background-imag=
e: initial; background-attachment: initial; background-size: initial; backg=
round-origin: initial; background-clip: initial; background-position: initi=
al; background-repeat: initial;">127.0.0.1"</span><span style=3D"font-size:=
 16pt; font-family: Consolas; color: black; background-image: initial; back=
ground-attachment: initial; background-size: initial; background-origin: in=
itial; background-clip: initial; background-position: initial; background-r=
epeat: initial;">,
1337);</span><span style=3D"font-size: 16pt; font-family: Consolas; color: =
black; background-image: initial; background-attachment: initial; backgroun=
d-size: initial; background-origin: initial; background-clip: initial; back=
ground-position: initial; background-repeat: initial;">&nbsp;&nbsp; </span>=
</p>

<p style=3D"margin-top: 0pt; margin-bottom: 0pt; margin-left: 0in; directio=
n: ltr; unicode-bidi: embed; word-break: normal;"><span style=3D"font-size:=
 16pt; font-family: Consolas; color: black; background-image: initial; back=
ground-attachment: initial; background-size: initial; background-origin: in=
itial; background-clip: initial; background-position: initial; background-r=
epeat: initial;">&nbsp;&nbsp;&nbsp; </span><span style=3D"font-size: 16pt; =
font-family: Consolas; color: blue; background-image: initial; background-a=
ttachment: initial; background-size: initial; background-origin: initial; b=
ackground-clip: initial; background-position: initial; background-repeat: i=
nitial;">do</span><span style=3D"font-size: 16pt; font-family: Consolas; co=
lor: black; background-image: initial; background-attachment: initial; back=
ground-size: initial; background-origin: initial; background-clip: initial;=
 background-position: initial; background-repeat: initial;">
</span></p>

<p style=3D"margin-top: 0pt; margin-bottom: 0pt; margin-left: 0in; directio=
n: ltr; unicode-bidi: embed; word-break: normal;"><span style=3D"font-size:=
 16pt; font-family: Consolas; color: black; background-image: initial; back=
ground-attachment: initial; background-size: initial; background-origin: in=
itial; background-clip: initial; background-position: initial; background-r=
epeat: initial;">&nbsp;&nbsp;&nbsp; {</span></p>

<p style=3D"margin-top: 0pt; margin-bottom: 0pt; margin-left: 0in; directio=
n: ltr; unicode-bidi: embed; word-break: normal;"><span style=3D"font-size:=
 16pt; font-family: Consolas; color: black; background-image: initial; back=
ground-attachment: initial; background-size: initial; background-origin: in=
itial; background-clip: initial; background-position: initial; background-r=
epeat: initial;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span st=
yle=3D"font-size: 16pt; font-family: Consolas; color: blue; background-imag=
e: initial; background-attachment: initial; background-size: initial; backg=
round-origin: initial; background-clip: initial; background-position: initi=
al; background-repeat: initial;">auto</span><span style=3D"font-size: 16pt;=
 font-family: Consolas; color: black; background-image: initial; background=
-attachment: initial; background-size: initial; background-origin: initial;=
 background-clip: initial; background-position: initial; background-repeat:=
 initial;">
</span><span style=3D"font-size: 16pt; font-family: Consolas; color: black;=
 background-image: initial; background-attachment: initial; background-size=
: initial; background-origin: initial; background-clip: initial; background=
-position: initial; background-repeat: initial;">bytesRead</span><span styl=
e=3D"font-size: 16pt; font-family: Consolas; color: black; background-image=
: initial; background-attachment: initial; background-size: initial; backgr=
ound-origin: initial; background-clip: initial; background-position: initia=
l; background-repeat: initial;">
=3D </span><span style=3D"font-size: 16pt; font-family: Consolas; color: bl=
ue; background-image: initial; background-attachment: initial; background-s=
ize: initial; background-origin: initial; background-clip: initial; backgro=
und-position: initial; background-repeat: initial;">await</span><span style=
=3D"font-size: 16pt; font-family: Consolas; color: black; background-image:=
 initial; background-attachment: initial; background-size: initial; backgro=
und-origin: initial; background-clip: initial; background-position: initial=
; background-repeat: initial;">
</span><span style=3D"font-size: 16pt; font-family: Consolas; color: black;=
 background-image: initial; background-attachment: initial; background-size=
: initial; background-origin: initial; background-clip: initial; background=
-position: initial; background-repeat: initial;">conn.Read</span><span styl=
e=3D"font-size: 16pt; font-family: Consolas; color: black; background-image=
: initial; background-attachment: initial; background-size: initial; backgr=
ound-origin: initial; background-clip: initial; background-position: initia=
l; background-repeat: initial;">(</span><span style=3D"font-size: 16pt; fon=
t-family: Consolas; color: black; background-image: initial; background-att=
achment: initial; background-size: initial; background-origin: initial; bac=
kground-clip: initial; background-position: initial; background-repeat: ini=
tial;">buf</span><span style=3D"font-size: 16pt; font-family: Consolas; col=
or: black; background-image: initial; background-attachment: initial; backg=
round-size: initial; background-origin: initial; background-clip: initial; =
background-position: initial; background-repeat: initial;">,
</span><span style=3D"font-size: 16pt; font-family: Consolas; color: blue; =
background-image: initial; background-attachment: initial; background-size:=
 initial; background-origin: initial; background-clip: initial; background-=
position: initial; background-repeat: initial;">sizeof</span><span style=3D=
"font-size: 16pt; font-family: Consolas; color: black; background-image: in=
itial; background-attachment: initial; background-size: initial; background=
-origin: initial; background-clip: initial; background-position: initial; b=
ackground-repeat: initial;">(</span><span style=3D"font-size: 16pt; font-fa=
mily: Consolas; color: black; background-image: initial; background-attachm=
ent: initial; background-size: initial; background-origin: initial; backgro=
und-clip: initial; background-position: initial; background-repeat: initial=
;">buf</span><span style=3D"font-size: 16pt; font-family: Consolas; color: =
black; background-image: initial; background-attachment: initial; backgroun=
d-size: initial; background-origin: initial; background-clip: initial; back=
ground-position: initial; background-repeat: initial;">));</span></p>

<p style=3D"margin-top: 0pt; margin-bottom: 0pt; margin-left: 0in; directio=
n: ltr; unicode-bidi: embed; word-break: normal;"><span style=3D"font-size:=
 16pt; font-family: Consolas; color: black; background-image: initial; back=
ground-attachment: initial; background-size: initial; background-origin: in=
itial; background-clip: initial; background-position: initial; background-r=
epeat: initial;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; total -=3D byte=
sRead</span><span style=3D"font-size: 16pt; font-family: Consolas; color: b=
lack; background-image: initial; background-attachment: initial; background=
-size: initial; background-origin: initial; background-clip: initial; backg=
round-position: initial; background-repeat: initial;">;</span></p>

<p style=3D"margin-top: 0pt; margin-bottom: 0pt; margin-left: 0in; directio=
n: ltr; unicode-bidi: embed; word-break: normal;"><span style=3D"font-size:=
 16pt; font-family: Consolas; color: black; background-image: initial; back=
ground-attachment: initial; background-size: initial; background-origin: in=
itial; background-clip: initial; background-position: initial; background-r=
epeat: initial;">&nbsp;</span><span style=3D"font-size: 16pt; font-family: =
Consolas; color: black; background-image: initial; background-attachment: i=
nitial; background-size: initial; background-origin: initial; background-cl=
ip: initial; background-position: initial; background-repeat: initial;">&nb=
sp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; result +=3D std::count(</span><span style=
=3D"font-size: 16pt; font-family: Consolas; color: black; background-image:=
 initial; background-attachment: initial; background-size: initial; backgro=
und-origin: initial; background-clip: initial; background-position: initial=
; background-repeat: initial;">buf</span><span style=3D"font-size: 16pt; fo=
nt-family: Consolas; color: black; background-image: initial; background-at=
tachment: initial; background-size: initial; background-origin: initial; ba=
ckground-clip: initial; background-position: initial; background-repeat: in=
itial;">,
</span><span style=3D"font-size: 16pt; font-family: Consolas; color: black;=
 background-image: initial; background-attachment: initial; background-size=
: initial; background-origin: initial; background-clip: initial; background=
-position: initial; background-repeat: initial;">buf</span><span style=3D"f=
ont-size: 16pt; font-family: Consolas; color: black; background-image: init=
ial; background-attachment: initial; background-size: initial; background-o=
rigin: initial; background-clip: initial; background-position: initial; bac=
kground-repeat: initial;">
+ bytesRead, </span><span style=3D"font-size: 16pt; font-family: Consolas; =
color: rgb(163, 21, 21); background-image: initial; background-attachment: =
initial; background-size: initial; background-origin: initial; background-c=
lip: initial; background-position: initial; background-repeat: initial;">'c=
'</span><span style=3D"font-size: 16pt; font-family: Consolas; color: black=
; background-image: initial; background-attachment: initial; background-siz=
e: initial; background-origin: initial; background-clip: initial; backgroun=
d-position: initial; background-repeat: initial;">);</span></p>

<p style=3D"margin-top: 0pt; margin-bottom: 0pt; margin-left: 0in; directio=
n: ltr; unicode-bidi: embed; word-break: normal;"><span style=3D"font-size:=
 16pt; font-family: Consolas; color: black; background-image: initial; back=
ground-attachment: initial; background-size: initial; background-origin: in=
itial; background-clip: initial; background-position: initial; background-r=
epeat: initial;">&nbsp;&nbsp;&nbsp; } </span></p>

<p style=3D"margin-top: 0pt; margin-bottom: 0pt; margin-left: 0in; directio=
n: ltr; unicode-bidi: embed; word-break: normal;"><span style=3D"font-size:=
 16pt; font-family: Consolas; color: black; background-image: initial; back=
ground-attachment: initial; background-size: initial; background-origin: in=
itial; background-clip: initial; background-position: initial; background-r=
epeat: initial;">&nbsp;&nbsp;&nbsp; </span><span style=3D"font-size: 16pt; =
font-family: Consolas; color: blue; background-image: initial; background-a=
ttachment: initial; background-size: initial; background-origin: initial; b=
ackground-clip: initial; background-position: initial; background-repeat: i=
nitial;">while</span><span style=3D"font-size: 16pt; font-family: Consolas;=
 color: black; background-image: initial; background-attachment: initial; b=
ackground-size: initial; background-origin: initial; background-clip: initi=
al; background-position: initial; background-repeat: initial;">
(total &gt; 0</span><span style=3D"font-size: 16pt; font-family: Consolas; =
color: black; background-image: initial; background-attachment: initial; ba=
ckground-size: initial; background-origin: initial; background-clip: initia=
l; background-position: initial; background-repeat: initial;">);</span></p>

<p style=3D"margin-top: 0pt; margin-bottom: 0pt; margin-left: 0in; directio=
n: ltr; unicode-bidi: embed; word-break: normal;"><span style=3D"font-size:=
 16pt; font-family: Consolas; color: black; background-image: initial; back=
ground-attachment: initial; background-size: initial; background-origin: in=
itial; background-clip: initial; background-position: initial; background-r=
epeat: initial;">&nbsp;</span><span style=3D"font-size: 16pt; font-family: =
Consolas; color: black; background-image: initial; background-attachment: i=
nitial; background-size: initial; background-origin: initial; background-cl=
ip: initial; background-position: initial; background-repeat: initial;">&nb=
sp;&nbsp; </span><span style=3D"font-size: 16pt; font-family: Consolas; col=
or: blue; background-image: initial; background-attachment: initial; backgr=
ound-size: initial; background-origin: initial; background-clip: initial; b=
ackground-position: initial; background-repeat: initial;">return</span><spa=
n style=3D"font-size: 16pt; font-family: Consolas; color: black; background=
-image: initial; background-attachment: initial; background-size: initial; =
background-origin: initial; background-clip: initial; background-position: =
initial; background-repeat: initial;">
result;</span></p>

<p style=3D"margin-top: 0pt; margin-bottom: 0pt; margin-left: 0in; directio=
n: ltr; unicode-bidi: embed; word-break: normal;"></p>

<p style=3D"margin-top: 0pt; margin-bottom: 0pt; margin-left: 0in; directio=
n: ltr; unicode-bidi: embed; word-break: normal;"><span style=3D"font-size:=
 16pt; font-family: Consolas; color: black; background-image: initial; back=
ground-attachment: initial; background-size: initial; background-origin: in=
itial; background-clip: initial; background-position: initial; background-r=
epeat: initial;">}</span></p><p style=3D"margin-top: 0pt; margin-bottom: 0p=
t; margin-left: 0in; direction: ltr; unicode-bidi: embed; word-break: norma=
l;"><span style=3D"font-size: 16pt; font-family: Consolas; color: black; ba=
ckground-image: initial; background-attachment: initial; background-size: i=
nitial; background-origin: initial; background-clip: initial; background-po=
sition: initial; background-repeat: initial;"><br></span></p><p style=3D"ma=
rgin-top: 0pt; margin-bottom: 0pt; margin-left: 0in; direction: ltr; unicod=
e-bidi: embed; word-break: normal;"><span style=3D"font-size: 16pt; font-fa=
mily: Consolas; color: black; background-image: initial; background-attachm=
ent: initial; background-size: initial; background-origin: initial; backgro=
und-clip: initial; background-position: initial; background-repeat: initial=
;"><span style=3D"color: rgb(34, 34, 34); font-family: Arial, Helvetica, sa=
ns-serif; font-size: 13px; line-height: normal;">Slide 9: where does the "c=
oroutine frame" live? I cannot convince myself this does not need runtime s=
upport of some kind,</span></span></p><p style=3D"margin-top: 0pt; margin-b=
ottom: 0pt; margin-left: 0in; direction: ltr; unicode-bidi: embed; word-bre=
ak: normal;"><span style=3D"font-size: 16pt; font-family: Consolas; color: =
black; background-image: initial; background-attachment: initial; backgroun=
d-size: initial; background-origin: initial; background-clip: initial; back=
ground-position: initial; background-repeat: initial;"><span style=3D"color=
: rgb(34, 34, 34); font-family: Arial, Helvetica, sans-serif; font-size: 13=
px; line-height: normal;">because that state must be managed by someone.&nb=
sp;</span></span></p><p style=3D"margin-top: 0pt; margin-bottom: 0pt; margi=
n-left: 0in; direction: ltr; unicode-bidi: embed; word-break: normal;"><spa=
n style=3D"font-size: 16pt; font-family: Consolas; color: black; background=
-image: initial; background-attachment: initial; background-size: initial; =
background-origin: initial; background-clip: initial; background-position: =
initial; background-repeat: initial;"><span style=3D"color: rgb(34, 34, 34)=
; font-family: Arial, Helvetica, sans-serif; font-size: 13px; line-height: =
normal;">Is this coroutine frame what can be controlled with the allocator =
(which would be good).</span></span></p><p style=3D"margin-top: 0pt; margin=
-bottom: 0pt; margin-left: 0in; direction: ltr; unicode-bidi: embed; word-b=
reak: normal;"><span style=3D"font-size: 16pt; font-family: Consolas; color=
: black; background-image: initial; background-attachment: initial; backgro=
und-size: initial; background-origin: initial; background-clip: initial; ba=
ckground-position: initial; background-repeat: initial;"><span style=3D"col=
or: rgb(34, 34, 34); font-family: Arial, Helvetica, sans-serif; font-size: =
13px; line-height: normal;"><br></span></span></p><p style=3D"margin-top: 0=
pt; margin-bottom: 0pt; margin-left: 0in; direction: ltr; unicode-bidi: emb=
ed; word-break: normal;"><span style=3D"font-size: 16pt; font-family: Conso=
las; color: black; background-image: initial; background-attachment: initia=
l; background-size: initial; background-origin: initial; background-clip: i=
nitial; background-position: initial; background-repeat: initial;"><span st=
yle=3D"color: rgb(34, 34, 34); font-family: Arial, Helvetica, sans-serif; f=
ont-size: 13px; line-height: normal;">A rough n4244 (pseudo boost.asio code=
 omitting error_code) would be like the following:</span></span></p><p styl=
e=3D"margin-top: 0pt; margin-bottom: 0pt; margin-left: 0in; direction: ltr;=
 unicode-bidi: embed; word-break: normal;"><br></p><p style=3D"margin-top: =
0pt; margin-bottom: 0pt; margin-left: 0in; direction: ltr; unicode-bidi: em=
bed; word-break: normal;">[](int total)&nbsp;resumable</p><p style=3D"margi=
n-top: 0pt; margin-bottom: 0pt; margin-left: 0in; direction: ltr; unicode-b=
idi: embed; word-break: normal;">{</p><p style=3D"margin-top: 0pt; margin-b=
ottom: 0pt; margin-left: 0in; direction: ltr; unicode-bidi: embed; word-bre=
ak: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; promis=
e&lt;ptrdiff_t&gt; p;</p><p style=3D"margin-top: 0pt; margin-bottom: 0pt; m=
argin-left: 0in; direction: ltr; unicode-bidi: embed; word-break: normal;">=
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; future&lt;ptrdiff_t=
&gt; res =3D p.get_future();</p><p style=3D"margin-top: 0pt; margin-bottom:=
 0pt; margin-left: 0in; direction: ltr; unicode-bidi: embed; word-break: no=
rmal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; char buf[64 =
* 1024];</p><p style=3D"margin-top: 0pt; margin-bottom: 0pt; margin-left: 0=
in; direction: ltr; unicode-bidi: embed; word-break: normal;">&nbsp; &nbsp;=
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ptrdiff_t result =3D 0; &nbsp;</=
p><p style=3D"margin-top: 0pt; margin-bottom: 0pt; margin-left: 0in; direct=
ion: ltr; unicode-bidi: embed; word-break: normal;">&nbsp; &nbsp; &nbsp; &n=
bsp; &nbsp; &nbsp; &nbsp; &nbsp; auto conn =3D yield async_connect(..., *[]=
this);</p><p style=3D"margin-top: 0pt; margin-bottom: 0pt; margin-left: 0in=
; direction: ltr; unicode-bidi: embed; word-break: normal;">&nbsp; &nbsp; &=
nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; do {</p><p style=3D"margin-top: 0p=
t; margin-bottom: 0pt; margin-left: 0in; direction: ltr; unicode-bidi: embe=
d; word-break: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &n=
bsp; &nbsp; auto bytes_read =3D yield conn.async_read(...., *[]this);</p><p=
 style=3D"margin-top: 0pt; margin-bottom: 0pt; margin-left: 0in; direction:=
 ltr; unicode-bidi: embed; word-break: normal;">&nbsp; &nbsp; &nbsp; &nbsp;=
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ...</p><p style=3D"margin-top: 0pt; mar=
gin-bottom: 0pt; margin-left: 0in; direction: ltr; unicode-bidi: embed; wor=
d-break: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }=
 while (total &lt; 0);</p><p style=3D"margin-top: 0pt; margin-bottom: 0pt; =
margin-left: 0in; direction: ltr; unicode-bidi: embed; word-break: normal;"=
><br></p><p style=3D"margin-top: 0pt; margin-bottom: 0pt; margin-left: 0in;=
 direction: ltr; unicode-bidi: embed; word-break: normal;">&nbsp; &nbsp; &n=
bsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; p.set_value(total);</p><p style=3D"=
margin-top: 0pt; margin-bottom: 0pt; margin-left: 0in; direction: ltr; unic=
ode-bidi: embed; word-break: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &n=
bsp; &nbsp; &nbsp; return res;</p><p style=3D"margin-top: 0pt; margin-botto=
m: 0pt; margin-left: 0in; direction: ltr; unicode-bidi: embed; word-break: =
normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;}</p><p style=3D"margin-top: 0pt=
; margin-bottom: 0pt; margin-left: 0in; direction: ltr; unicode-bidi: embed=
; word-break: normal;">}</p><div><br></div><div>I admit in n4134 it is a bi=
t easier to write, but, if I am not wrong, not without its costs.</div><div=
><br></div><div>n4134:</div><div><br></div><div>+ Easier to write.</div><di=
v>+ Customizable to more than futures: good, but read below.<br></div><div>=
<div>+/- At the same time, it is hiding me the promise parts of things in t=
hat piece of code.</div></div><div>This is a double edged sword because it =
is convenient but makes reasoning about what</div><div>happens harder, and =
possible defficiencies in performance hidden.</div><div>- Non/local state "=
somewhere". Where?</div><div><br></div><div>n4244:</div><div><br></div><div=
>- Harder to write. Though, I do know where all things are: inside the obje=
ct, because all the state is kept around.</div><div>+ Easy to reason about =
copy/move.</div><div>+ I dont need even to think of customizations, I could=
 return anything: just put it in the lambda body, it is gonna be saved</div=
><div>&nbsp; &nbsp;in the object, locally. This eliminates the need for tra=
its, it is just a function object!</div><div>+ Local state is inside the ob=
ject.</div><div><br></div><div>Biggest concerns from n4134:&nbsp;</div><div=
>&nbsp;</div><div>- heap allocations by default? Need customization point o=
nly for this? Wouldn't be better to avoid heap in the first place? Is it po=
ssible/feasible?</div><div>- copy/move a coroutine: I am not sure how it wo=
rks, not all the state is local. Easier for me to reason about n4244 in thi=
s sense.</div><div><br></div><div>P.S.: Feel free to criticize the most you=
 can :D Sorry if there are some assumptions/mistakes that don't hold true a=
t some point.</div><div>This is my feedback as I understand both proposals,=
 but I can never understand them as deeply as the writers of both.</div><di=
v><br></div><p style=3D"margin-top: 0pt; margin-bottom: 0pt; margin-left: 0=
in; direction: ltr; unicode-bidi: embed; word-break: normal;">Regards,</p><=
p style=3D"margin-top: 0pt; margin-bottom: 0pt; margin-left: 0in; direction=
: ltr; unicode-bidi: embed; word-break: normal;">Germ=C3=A1n Diago G=C3=B3m=
ez</p><p style=3D"margin-top: 0pt; margin-bottom: 0pt; margin-left: 0in; di=
rection: ltr; unicode-bidi: embed; word-break: normal;"><br></p></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&quot; group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<br />
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/">http://groups.google.com/a/isocpp.org/group/std-proposals/<=
/a>.<br />

------=_Part_57_939632687.1414390025589--

.