220 14241 <8ebf3c43-0d6d-4bcf-b647-00209eda4d71@isocpp.org> article
Path: news.gmane.org!not-for-mail
From: german.gomez@personifyinc.com
Newsgroups: gmane.comp.lang.c++.isocpp.proposals
Subject: =?ISO-8859-1?Q?=5Bstd=2Dproposals=5D_Re=3A_Question_for_Germ=E1n_Diago=3A_N413?=
	=?ISO-8859-1?Q?4_and_N4244?=
Date: Sun, 26 Oct 2014 23:07:05 -0700 (PDT)
Lines: 678
Approved: news@gmane.org
Message-ID: <8ebf3c43-0d6d-4bcf-b647-00209eda4d71@isocpp.org>
References: <44e2f2f7-aff5-4cfa-86ff-aefad5b971ab@isocpp.org>
Reply-To: std-proposals@isocpp.org
NNTP-Posting-Host: plane.gmane.org
Mime-Version: 1.0
Content-Type: multipart/alternative; 
	boundary="----=_Part_57_939632687.1414390025589"
X-Trace: ger.gmane.org 1414390036 20435 80.91.229.3 (27 Oct 2014 06:07:16 GMT)
X-Complaints-To: usenet@ger.gmane.org
NNTP-Posting-Date: Mon, 27 Oct 2014 06:07:16 +0000 (UTC)
To: std-proposals@isocpp.org
Original-X-From: std-proposals+bncBDWYPV7DUIFRBC6CW6RAKGQEDZOZUXA@isocpp.org Mon Oct 27 07:07:10 2014
Return-path: <std-proposals+bncBDWYPV7DUIFRBC6CW6RAKGQEDZOZUXA@isocpp.org>
Envelope-to: gclcip-std-proposals@m.gmane.org
Original-Received: from mail-ob0-f198.google.com ([209.85.214.198])
	by plane.gmane.org with esmtp (Exim 4.69)
	(envelope-from <std-proposals+bncBDWYPV7DUIFRBC6CW6RAKGQEDZOZUXA@isocpp.org>)
	id 1XidSP-0001ox-1S
	for gclcip-std-proposals@m.gmane.org; Mon, 27 Oct 2014 07:07:09 +0100
Original-Received: by mail-ob0-f198.google.com with SMTP id m8sf8120888obr.5
        for <gclcip-std-proposals@m.gmane.org>; Sun, 26 Oct 2014 23:07:07 -0700 (PDT)
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20130820;
        h=x-gm-message-state:date:from:to:message-id:in-reply-to:references
         :subject:mime-version:x-original-sender:reply-to:precedence
         :mailing-list:list-id:list-post:list-help:list-archive
         :list-subscribe:list-unsubscribe:content-type;
        bh=2XVxfi3KlngSgr/aEORrxbBE0G28M/OsuoaNvsxss9E=;
        b=QDDxx2CMxB8QOjs9k3NsXIrxxBsY6SNC2vTDAdevBnq+xx6IbefwXpCtugMbZiwcgM
         H3Dk6CB2QDv28+I5+MLZ7mjBk9cYLvJhlyAZzIL77WwwwNAikJcuKIXHPfJI+ev5iVJY
         EnkcK7zdwZ/Fv64BP0MDB9Ot/oxOfne8o9XKBZhodLjj8+GXsNi77ngNgLf3ng3D5py8
         eIXISmGgh42bmQW/QVbJQVpJLMP1DSvQOhLQe8Vv7FkPmJZK7m27I5XfPj7B8gmTsoXB
         zBQ60cg+77gGNanmXcbmAyjkybnPCpGH3sKGQo8H4psjC9WZDGpDm531w3S6JcMA0Ew8
         jWTg==
X-Gm-Message-State: ALoCoQmYBvYDgz+3GqvXDCN6dRhx5TlKDb7tYg8hf4ABatf1PhD177RAbK6TmxV9tOx6SFm7StpA
X-Received: by 10.182.27.244 with SMTP id w20mr12417539obg.46.1414390027772;
        Sun, 26 Oct 2014 23:07:07 -0700 (PDT)
X-BeenThere: std-proposals@isocpp.org
Original-Received: by 10.107.166.195 with SMTP id p186ls1250602ioe.96.gmail; Sun, 26
 Oct 2014 23:07:07 -0700 (PDT)
X-Received: by 10.50.138.40 with SMTP id qn8mr195335igb.2.1414390027060;
        Sun, 26 Oct 2014 23:07:07 -0700 (PDT)
In-Reply-To: <44e2f2f7-aff5-4cfa-86ff-aefad5b971ab@isocpp.org>
X-Original-Sender: german.gomez@personifyinc.com
Precedence: list
Mailing-list: list std-proposals@isocpp.org; contact std-proposals+owners@isocpp.org
List-ID: <std-proposals.isocpp.org>
X-Google-Group-Id: 399137483710
List-Post: <http://groups.google.com/a/isocpp.org/group/std-proposals/post>, <mailto:std-proposals@isocpp.org>
List-Help: <http://support.google.com/a/isocpp.org/bin/topic.py?topic=25838>, <mailto:std-proposals+help@isocpp.org>
List-Archive: <http://groups.google.com/a/isocpp.org/group/std-proposals/>
List-Subscribe: <http://groups.google.com/a/isocpp.org/group/std-proposals/subscribe>,
 <mailto:std-proposals+subscribe@isocpp.org>
List-Unsubscribe: <mailto:googlegroups-manage+399137483710+unsubscribe@googlegroups.com>,
 <http://groups.google.com/a/isocpp.org/group/std-proposals/subscribe>
Xref: news.gmane.org gmane.comp.lang.c++.isocpp.proposals:14241
Archived-At: <http://permalink.gmane.org/gmane.comp.lang.c++.isocpp.proposals/14241>

------=_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--

.
