220 14208 <40b956e0-af26-42db-a9f1-ce327e47e6ef@isocpp.org> article
Path: news.gmane.org!not-for-mail
From: Gor Nishanov <gornishanov@gmail.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: Sat, 25 Oct 2014 07:30:14 -0700 (PDT)
Lines: 765
Approved: news@gmane.org
Message-ID: <40b956e0-af26-42db-a9f1-ce327e47e6ef@isocpp.org>
References: <44e2f2f7-aff5-4cfa-86ff-aefad5b971ab@isocpp.org>
 <1ae62993-e2dc-4a1c-a1c3-4720cf56f9b0@isocpp.org>
Reply-To: std-proposals@isocpp.org
NNTP-Posting-Host: plane.gmane.org
Mime-Version: 1.0
Content-Type: multipart/alternative; 
	boundary="----=_Part_1911_1339040544.1414247414034"
X-Trace: ger.gmane.org 1414247424 4174 80.91.229.3 (25 Oct 2014 14:30:24 GMT)
X-Complaints-To: usenet@ger.gmane.org
NNTP-Posting-Date: Sat, 25 Oct 2014 14:30:24 +0000 (UTC)
To: std-proposals@isocpp.org
Original-X-From: std-proposals+bncBC47RF4IW4GRB57HV2RAKGQEC6HCDHI@isocpp.org Sat Oct 25 16:30:17 2014
Return-path: <std-proposals+bncBC47RF4IW4GRB57HV2RAKGQEC6HCDHI@isocpp.org>
Envelope-to: gclcip-std-proposals@m.gmane.org
Original-Received: from mail-yh0-f72.google.com ([209.85.213.72])
	by plane.gmane.org with esmtp (Exim 4.69)
	(envelope-from <std-proposals+bncBC47RF4IW4GRB57HV2RAKGQEC6HCDHI@isocpp.org>)
	id 1Xi2MD-0006UM-Ah
	for gclcip-std-proposals@m.gmane.org; Sat, 25 Oct 2014 16:30:17 +0200
Original-Received: by mail-yh0-f72.google.com with SMTP id a41sf9931919yho.3
        for <gclcip-std-proposals@m.gmane.org>; Sat, 25 Oct 2014 07:30:16 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=gmail.com; s=20120113;
        h=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=ZZ2DB9yZaAvKg43Eaw953zIZG+8TRNsiMiLroSLJXr4=;
        b=Mi2H6tbKz8V0PfV9HJPfuPQ9uFhIBVOxI/LmRwUoTXGx+75bbDiCYdcc+MIFDMibml
         cpk6obLVgTfKN6kHZe2BTPkzoJoNlj78MofQlsybMsLPcZk78XIe47HwOLuR3MCOt/zy
         WB01PyzTgFA90hMp/u9jOYM8LjeQ9z1vmif/e+pcLdZbNmZ7ICqREtkBfUBQ2p4hx/ba
         GcWsF8OjPsuVWmcl3CQxZQxGzj4dD6CCgYcyVi9mGiC2bG+k0XOpMve4Pz8BxefOP9tG
         3vVKi1v3pzM5dcCVi+dVkBgnOi5KQKqSKXfXr6mHHZpk4mXi8VtuW3a/TzV2LhKa/HJm
         /DPw==
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=ZZ2DB9yZaAvKg43Eaw953zIZG+8TRNsiMiLroSLJXr4=;
        b=cWpn3XCkNEzgkodkwdzt+Hcu+5m4Z4uFqtMuwU0RcY5Tvn9Vj1nF8TkzTp9aZH0xsP
         l9r1zzjyNHB0njKODzdj6m43FYLihECaVUHSLTQ6ZpxPM14eEsHL3SwAaWiNELQ6+g9B
         GrwZTN/8/PnO8sXACAsD23zztkXJSKyiuriEiLneXSc+Za0cbcqTrNQTKMe3kV9U3suI
         q1B0GRkoNJ7OATROiy5YAckRl6ryFrcKkFkkya2n/IHZVzIKfwyYzJDgQmhFrZrW9j6p
         H1tra0ceORsC7moV208sEblQmg8N5zt6HsuXpRFu4HQ04YYNhAMnZGyX/hLIqCDyO2PD
         VtwA==
X-Gm-Message-State: ALoCoQlQLk/w3jzKBFN8xM4HTu5vwYRQ4vThFNxER1TG6GURxmWjV8o2ZGctxXS2Mx+OKTfIRZ+b
X-Received: by 10.52.17.170 with SMTP id p10mr12467664vdd.6.1414247416375;
        Sat, 25 Oct 2014 07:30:16 -0700 (PDT)
X-BeenThere: std-proposals@isocpp.org
Original-Received: by 10.107.40.202 with SMTP id o193ls1474461ioo.10.gmail; Sat, 25 Oct
 2014 07:30:15 -0700 (PDT)
X-Received: by 10.50.134.69 with SMTP id pi5mr119651igb.2.1414247415648;
        Sat, 25 Oct 2014 07:30:15 -0700 (PDT)
In-Reply-To: <1ae62993-e2dc-4a1c-a1c3-4720cf56f9b0@isocpp.org>
X-Original-Sender: GorNishanov@gmail.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:14208
Archived-At: <http://permalink.gmane.org/gmane.comp.lang.c++.isocpp.proposals/14208>

------=_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--

.
