220 21783 <d3723a3d-1b73-4c6c-bc7f-3d224d2ec8a2@isocpp.org> article
Path: news.gmane.org!not-for-mail
From: Evgeny Panasyuk <evgeny.panasyuk@gmail.com>
Newsgroups: gmane.comp.lang.c++.isocpp.proposals
Subject: Re: is await an extension of the do-notation? (was Re:
 Re: Resumable expressions p0114r0 vs async/await P0057R0)
Date: Wed, 14 Oct 2015 11:29:22 -0700 (PDT)
Lines: 524
Approved: news@gmane.org
Message-ID: <d3723a3d-1b73-4c6c-bc7f-3d224d2ec8a2@isocpp.org>
References: <639f0012-8cb4-4db3-82a6-8d042a3497f9@isocpp.org>
 <401aa118-ed0b-4c7b-92cf-3fbd706eff9d@isocpp.org>
 <fcbcc1c4-535c-4fa2-a17d-4acffe84a4b5@isocpp.org>
 <1d15dbc4-e0c1-4df1-86db-014e11f14d26@isocpp.org>
 <56114953.4030701@wanadoo.fr> <561B403D.4030403@gmail.com>
 <CAOfiQqkKvZfVatJ1Bz4qSvGc-g6iep0xeP1B1=J1-gCu43NXxg@mail.gmail.com>
 <561C07D1.3080304@gmail.com>
 <CAOfiQqnR4GYCttwu8G-44_UEN4WekW19uorEvf-5VC3vOpej-g@mail.gmail.com>
 <561C213F.1060009@gmail.com>
 <fb82d876-8a54-4c28-8e53-297018470cf6@isocpp.org>
 <561C3875.2050701@gmail.com>
 <86924069-44d0-447f-bf8a-a42e46579832@isocpp.org>
 <561D79A7.8080007@gmail.com>
 <894616d6-9609-4038-b2bc-d2c62df21e0f@isocpp.org>
 <99bdb3ae-9214-4440-8572-4c47a61eda46@isocpp.org>
 <58628096-14ae-42b2-89d3-c0bd2183bbc0@isocpp.org>
 <561DC957.8080603@gmail.com>
 <a44dae17-5f63-4c60-a943-d74a1332b54c@isocpp.org>
Reply-To: std-proposals@isocpp.org
NNTP-Posting-Host: plane.gmane.org
Mime-Version: 1.0
Content-Type: multipart/mixed; 
	boundary="----=_Part_418_1074316711.1444847362386"
X-Trace: ger.gmane.org 1444847367 641 80.91.229.3 (14 Oct 2015 18:29:27 GMT)
X-Complaints-To: usenet@ger.gmane.org
NNTP-Posting-Date: Wed, 14 Oct 2015 18:29:27 +0000 (UTC)
To: ISO C++ Standard - Future Proposals <std-proposals@isocpp.org>
Original-X-From: std-proposals+bncBC54TLGKR4LBBA567KYAKGQEDXKRUWI@isocpp.org Wed Oct 14 20:29:27 2015
Return-path: <std-proposals+bncBC54TLGKR4LBBA567KYAKGQEDXKRUWI@isocpp.org>
Envelope-to: gclcip-std-proposals@m.gmane.org
Original-Received: from mail-pa0-f70.google.com ([209.85.220.70])
	by plane.gmane.org with esmtp (Exim 4.69)
	(envelope-from <std-proposals+bncBC54TLGKR4LBBA567KYAKGQEDXKRUWI@isocpp.org>)
	id 1ZmQnm-0007WY-2W
	for gclcip-std-proposals@m.gmane.org; Wed, 14 Oct 2015 20:29:26 +0200
Original-Received: by palb17 with SMTP id b17sf105771794pal.3
        for <gclcip-std-proposals@m.gmane.org>; Wed, 14 Oct 2015 11:29:24 -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
         :content-type:x-original-sender:reply-to:precedence:mailing-list
         :list-id:x-spam-checked-in-group:list-post:list-help:list-archive
         :list-subscribe:list-unsubscribe;
        bh=XM41U84l9r/c7FalPfLB8QG76WLKu5KLjefUheL6Nnk=;
        b=xlTM5O4yOzQEoLatrCheErKyZXxqQCoAMv2vCRtRHY50N7lXuka2WKAO86cANAHuK3
         tZJUPXgiexIxBaUvaoQ74c6Fsrg27DBX1NpOAF9ZzSjIMrF9rrsPdzZy8YjadIZLZtEK
         PS1BYVQyxpdq/yp6rqB88vaXgdZORmnBzOUhGvepRJ8w6146ImLSIEeXPRpjJ4TTHk1X
         hboqbpLopmbzTUd0cJ+FI0RvVTxbBPPbBu1Jl5vJk/yqI9S2BvHBRiosCHkk7lvc/UAF
         vYGKRAUI/zCR4i3uEGlyChG5sRIFPg0rsAloY/xVqGqOfleLDjgr66dAsWb/F9XHTMdU
         +s3A==
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:content-type:x-original-sender:reply-to
         :precedence:mailing-list:list-id:x-spam-checked-in-group:list-post
         :list-help:list-archive:list-subscribe:list-unsubscribe;
        bh=XM41U84l9r/c7FalPfLB8QG76WLKu5KLjefUheL6Nnk=;
        b=aSbamqeDA2fdmohnNITbAFOZVuZZoQ1B4c4MrPbF6sHpkWAR2Z4LW/pJXPL5g5K8yq
         8wUxF9O84iYq7tEUVKnLHrUZt1OEv+ScgCbB93K/WGojtfc0zf6QIRzTZL+rntvgqIVR
         z/eRgQ4287Zuv4+FX5fxC0pTUpn1QGNkXS4M97nkdcZrkC6i48JJiX9AXqBCn9geP0Jw
         59WlYGOmH2NRxaSG6iKHMatm6Hm6FKSiyeVtHMWsB40UAgsQ8ZcPcjZVzBOmhdrCyLcm
         1toXgR6VlKQD6iy04ghC6dHukdguZ1SV53JH3E5iP2pBzUIlfs94bD7sBtnsK8SmNKQ6
         pLyQ==
X-Gm-Message-State: ALoCoQkWR4NWe507qWtfrsYnc9t2KZg5tfrk3FjLMfBCAmi8NUEctJqbR2hC8jgT5DcRg/RLvHB8
X-Received: by 10.66.229.69 with SMTP id so5mr3874459pac.26.1444847364665;
        Wed, 14 Oct 2015 11:29:24 -0700 (PDT)
X-BeenThere: std-proposals@isocpp.org
Original-Received: by 10.50.20.201 with SMTP id p9ls253035ige.44.gmail; Wed, 14 Oct
 2015 11:29:23 -0700 (PDT)
X-Received: by 10.50.73.233 with SMTP id o9mr73539igv.6.1444847363316;
        Wed, 14 Oct 2015 11:29:23 -0700 (PDT)
In-Reply-To: <a44dae17-5f63-4c60-a943-d74a1332b54c@isocpp.org>
X-Original-Sender: Evgeny.Panasyuk@gmail.com
Precedence: list
Mailing-list: list std-proposals@isocpp.org; contact std-proposals+owners@isocpp.org
List-ID: <std-proposals.isocpp.org>
X-Spam-Checked-In-Group: 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:21783
Archived-At: <http://permalink.gmane.org/gmane.comp.lang.c++.isocpp.proposals/21783>

------=_Part_418_1074316711.1444847362386
Content-Type: multipart/alternative; 
	boundary="----=_Part_419_1957335235.1444847362387"

------=_Part_419_1957335235.1444847362387
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

14 October 2015 =D0=B3., 7:46:51 UTC+3 Nicol Bolas :
>
>
> Thus far, including in this post, you haven't mentioned an example that=
=20
> would actually compile.
>
>
Actually examples do compile and do run.
=20

> You linked to some macro code, but macros are, basically, *cheating*.=20
> They get to break all kinds of C++ rules, which an actual language featur=
e=20
> would not.
>

Macros allow us to emulate language feature, to test it now, with current=
=20
compilers. Even Stroustrup uses macros in Mach7 library to emulate language=
=20
feature.
I think it is obvious that following macro-based code:
COROUTINE(vector<int>, list_demo, (int, param),
    (int, local_x)
    (int, local_y))
{
    AWAIT(local_x =3D) vector<int>{1,2,3};
    AWAIT(local_y =3D) vector<int>{10, 20, 30};

    RETURN(local_x + local_y + param);
}
COROUTINE_END;

Is equivalent to following code with language support:

vector<int> list_demo(int param)
{
    int local_x =3D await vector<int>{1,2,3};
    int local_y =3D await vector<int>{10, 20, 30};
  =20
    return local_x + local_y + param;
}

And if macro-based version does work, then this one will work without=20
problems.


=20
>
>> >=20
>> > Also... how does `vector<coroutine>` make any kind of sense with regar=
d=20
>> > to P0114? The type isn't type erased, so each coroutine has its own=20
>> > type. Therefore, in order to put them in a homogeneous container like=
=20
>> > `vector`, you'll have to type-erase them. Which requires memory=20
>> allocation.=20
>>  > At which point, your version gains /nothing/ over P0057.=20
>>
>> Same coroutines have same concrete types. For instance, with P0114 it=20
>> may be:=20
>> |=20
>> struct concrete_coroutine=20
>> {=20
>>      resumable auto r =3D expression;=20
>>      // ...=20
>> };=20
>> ...=20
>> make_unique<concrete_coroutine[]>(N);=20
>> |
>>
>
> `auto` doesn't work that way. Non-static data members cannot be `auto`.=
=20
> Normally I wouldn't care about a small issue like that, but it basically=
=20
> makes your code impossible.
>


Such usage of auto is at p0114r0.pdf at page 11.
=20

>
> Without `auto` NSDMI (and I wouldn't hold my breath on seeing it=20
> <http://www.open-std.org/JTC1/SC22/WG21/docs/papers/2014/n3897.html>),=20
> you can't store a resumable expression. So you can't make containers of=
=20
> them.
>
> Unless you erase their types. So again, you've gained *nothing*.
>
> Your macro solution gets around this because it uses macros.
> =20
>

I showed two versions above - macro based version and possible syntax with=
=20
language support.
Do you have any concrete reasoning why it would be impossible without=20
macros?
=20

> Again, I am not talking specifically about P0114. Even P0057 can be=20
>> changed to have concrete coroutine type.=20
>>
>
> I'd be curious to see how, exactly.
>
>
Currently it works like this:
struct generator
{
     ...
     coroutine_handle<promise_type> coro;
};

generator example_generator()
{
    yield 1;
}

int main()
{
    generator x =3D example_generator();
    x.move_next();
    g.current_value();
}

With concrete coroutine type it could be something like this:

template<template<typename> class coroutine_value>
struct generator
{
     ...
     coroutine_value<promise_type> coro;
};

generator example_generator()
{
    yield 1;
}
// example_generator is transformed to:
using example_generator =3D generator< synthesized_coroutine >;

int main()
{
    example_generator x{};
    x.move_next();
    g.current_value();
}

=20

>
> If you want this done, then you're going to need to go through the effort=
=20
> of designing the feature to work without type erasure. Then you have to g=
et=20
> someone to implement it.
>

It could be implemented even with macros, to some extent. And I think=20
macro-based solution is enough for proof-of-concept.
=20

> Then, you can know whether it works just as well as P0057, whether it's=
=20
> equally easy to use, and how much of a performance advantage it gets.
>
> If any.
>

Of course it gives performance advantage, because does not impose extra=20
mandatory allocation.=20

--=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_419_1957335235.1444847362387
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr">14 October 2015 =D0=B3., 7:46:51 UTC+3 Nicol Bolas :<block=
quote class=3D"gmail_quote" style=3D"margin: 0;margin-left: 0.8ex;border-le=
ft: 1px #ccc solid;padding-left: 1ex;"><br><div>Thus far, including in this=
 post, you haven&#39;t mentioned an example that would actually compile.<br=
><br></div></blockquote><div><br>Actually examples do compile and do run.<b=
r>=C2=A0</div><blockquote class=3D"gmail_quote" style=3D"margin: 0;margin-l=
eft: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;"><div>You linked =
to some macro code, but macros are, basically, <i>cheating</i>. They get to=
 break all kinds of C++ rules, which an actual language feature would not.<=
br></div></blockquote><div><br>Macros allow us to emulate language feature,=
 to test it now, with current compilers. Even Stroustrup uses macros in Mac=
h7 library to emulate language feature.<br>I think it is obvious that follo=
wing macro-based code:<br><div class=3D"prettyprint" style=3D"background-co=
lor: rgb(250, 250, 250); border-color: rgb(187, 187, 187); border-style: so=
lid; border-width: 1px; word-wrap: break-word;"><code class=3D"prettyprint"=
><div class=3D"subprettyprint"><span style=3D"color: #000;" class=3D"styled=
-by-prettify">COROUTINE</span><span style=3D"color: #660;" class=3D"styled-=
by-prettify">(</span><span style=3D"color: #000;" class=3D"styled-by-pretti=
fy">vector</span><span style=3D"color: #080;" class=3D"styled-by-prettify">=
&lt;int&gt;</span><span style=3D"color: #660;" class=3D"styled-by-prettify"=
>,</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> list_de=
mo</span><span style=3D"color: #660;" class=3D"styled-by-prettify">,</span>=
<span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span sty=
le=3D"color: #660;" class=3D"styled-by-prettify">(</span><span style=3D"col=
or: #008;" class=3D"styled-by-prettify">int</span><span style=3D"color: #66=
0;" class=3D"styled-by-prettify">,</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"> param</span><span style=3D"color: #660;" class=3D"=
styled-by-prettify">),</span><span style=3D"color: #000;" class=3D"styled-b=
y-prettify"><br>=C2=A0 =C2=A0 </span><span style=3D"color: #660;" class=3D"=
styled-by-prettify">(</span><span style=3D"color: #008;" class=3D"styled-by=
-prettify">int</span><span style=3D"color: #660;" class=3D"styled-by-pretti=
fy">,</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> loca=
l_x</span><span style=3D"color: #660;" class=3D"styled-by-prettify">)</span=
><span style=3D"color: #000;" class=3D"styled-by-prettify"><br>=C2=A0 =C2=
=A0 </span><span style=3D"color: #660;" class=3D"styled-by-prettify">(</spa=
n><span style=3D"color: #008;" class=3D"styled-by-prettify">int</span><span=
 style=3D"color: #660;" class=3D"styled-by-prettify">,</span><span style=3D=
"color: #000;" class=3D"styled-by-prettify"> local_y</span><span style=3D"c=
olor: #660;" class=3D"styled-by-prettify">))</span><span style=3D"color: #0=
00;" class=3D"styled-by-prettify"><br></span><span style=3D"color: #660;" c=
lass=3D"styled-by-prettify">{</span><span style=3D"color: #000;" class=3D"s=
tyled-by-prettify"><br>=C2=A0 =C2=A0 AWAIT</span><span style=3D"color: #660=
;" class=3D"styled-by-prettify">(</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify">local_x </span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">=3D)</span><span style=3D"color: #000;" class=3D"st=
yled-by-prettify"> vector</span><span style=3D"color: #080;" class=3D"style=
d-by-prettify">&lt;int&gt;</span><span style=3D"color: #660;" class=3D"styl=
ed-by-prettify">{</span><span style=3D"color: #066;" class=3D"styled-by-pre=
ttify">1</span><span style=3D"color: #660;" class=3D"styled-by-prettify">,<=
/span><span style=3D"color: #066;" class=3D"styled-by-prettify">2</span><sp=
an style=3D"color: #660;" class=3D"styled-by-prettify">,</span><span style=
=3D"color: #066;" class=3D"styled-by-prettify">3</span><span style=3D"color=
: #660;" class=3D"styled-by-prettify">};</span><span style=3D"color: #000;"=
 class=3D"styled-by-prettify"><br>=C2=A0 =C2=A0 AWAIT</span><span style=3D"=
color: #660;" class=3D"styled-by-prettify">(</span><span style=3D"color: #0=
00;" class=3D"styled-by-prettify">local_y </span><span style=3D"color: #660=
;" class=3D"styled-by-prettify">=3D)</span><span style=3D"color: #000;" cla=
ss=3D"styled-by-prettify"> vector</span><span style=3D"color: #080;" class=
=3D"styled-by-prettify">&lt;int&gt;</span><span style=3D"color: #660;" clas=
s=3D"styled-by-prettify">{</span><span style=3D"color: #066;" class=3D"styl=
ed-by-prettify">10</span><span style=3D"color: #660;" class=3D"styled-by-pr=
ettify">,</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> =
</span><span style=3D"color: #066;" class=3D"styled-by-prettify">20</span><=
span style=3D"color: #660;" class=3D"styled-by-prettify">,</span><span styl=
e=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"colo=
r: #066;" class=3D"styled-by-prettify">30</span><span style=3D"color: #660;=
" class=3D"styled-by-prettify">};</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"><br><br>=C2=A0 =C2=A0 RETURN</span><span style=3D"c=
olor: #660;" class=3D"styled-by-prettify">(</span><span style=3D"color: #00=
0;" class=3D"styled-by-prettify">local_x </span><span style=3D"color: #660;=
" class=3D"styled-by-prettify">+</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"> local_y </span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">+</span><span style=3D"color: #000;" class=3D"style=
d-by-prettify"> param</span><span style=3D"color: #660;" class=3D"styled-by=
-prettify">);</span><span style=3D"color: #000;" class=3D"styled-by-prettif=
y"><br></span><span style=3D"color: #660;" class=3D"styled-by-prettify">}</=
span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br>COROUTIN=
E_END</span><span style=3D"color: #660;" class=3D"styled-by-prettify">;</sp=
an></div></code></div><br>Is equivalent to following code with language sup=
port:<br><br><div class=3D"prettyprint" style=3D"background-color: rgb(250,=
 250, 250); border-color: rgb(187, 187, 187); border-style: solid; border-w=
idth: 1px; word-wrap: break-word;"><code class=3D"prettyprint"><div class=
=3D"subprettyprint"><span style=3D"color: #000;" class=3D"styled-by-prettif=
y">vector</span><span style=3D"color: #080;" class=3D"styled-by-prettify">&=
lt;int&gt;</span><span style=3D"color: #000;" class=3D"styled-by-prettify">=
 list_demo</span><span style=3D"color: #660;" class=3D"styled-by-prettify">=
(</span><span style=3D"color: #008;" class=3D"styled-by-prettify">int</span=
><span style=3D"color: #000;" class=3D"styled-by-prettify"> param</span><sp=
an style=3D"color: #660;" class=3D"styled-by-prettify">)</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"><br></span><span style=3D"co=
lor: #660;" class=3D"styled-by-prettify">{</span><span style=3D"color: #000=
;" class=3D"styled-by-prettify"><br>=C2=A0 =C2=A0 </span><span style=3D"col=
or: #008;" class=3D"styled-by-prettify">int</span><span style=3D"color: #00=
0;" class=3D"styled-by-prettify"> local_x </span><span style=3D"color: #660=
;" class=3D"styled-by-prettify">=3D</span><span style=3D"color: #000;" clas=
s=3D"styled-by-prettify"> await vector</span><span style=3D"color: #080;" c=
lass=3D"styled-by-prettify">&lt;int&gt;</span><span style=3D"color: #660;" =
class=3D"styled-by-prettify">{</span><span style=3D"color: #066;" class=3D"=
styled-by-prettify">1</span><span style=3D"color: #660;" class=3D"styled-by=
-prettify">,</span><span style=3D"color: #066;" class=3D"styled-by-prettify=
">2</span><span style=3D"color: #660;" class=3D"styled-by-prettify">,</span=
><span style=3D"color: #066;" class=3D"styled-by-prettify">3</span><span st=
yle=3D"color: #660;" class=3D"styled-by-prettify">};</span><span style=3D"c=
olor: #000;" class=3D"styled-by-prettify"><br>=C2=A0 =C2=A0 </span><span st=
yle=3D"color: #008;" class=3D"styled-by-prettify">int</span><span style=3D"=
color: #000;" class=3D"styled-by-prettify"> local_y </span><span style=3D"c=
olor: #660;" class=3D"styled-by-prettify">=3D</span><span style=3D"color: #=
000;" class=3D"styled-by-prettify"> await vector</span><span style=3D"color=
: #080;" class=3D"styled-by-prettify">&lt;int&gt;</span><span style=3D"colo=
r: #660;" class=3D"styled-by-prettify">{</span><span style=3D"color: #066;"=
 class=3D"styled-by-prettify">10</span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">,</span><span style=3D"color: #000;" class=3D"style=
d-by-prettify"> </span><span style=3D"color: #066;" class=3D"styled-by-pret=
tify">20</span><span style=3D"color: #660;" class=3D"styled-by-prettify">,<=
/span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><sp=
an style=3D"color: #066;" class=3D"styled-by-prettify">30</span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">};</span><span style=3D"colo=
r: #000;" class=3D"styled-by-prettify"><br>=C2=A0 =C2=A0<br>=C2=A0 =C2=A0 <=
/span><span style=3D"color: #008;" class=3D"styled-by-prettify">return</spa=
n><span style=3D"color: #000;" class=3D"styled-by-prettify"> local_x </span=
><span style=3D"color: #660;" class=3D"styled-by-prettify">+</span><span st=
yle=3D"color: #000;" class=3D"styled-by-prettify"> local_y </span><span sty=
le=3D"color: #660;" class=3D"styled-by-prettify">+</span><span style=3D"col=
or: #000;" class=3D"styled-by-prettify"> param</span><span style=3D"color: =
#660;" class=3D"styled-by-prettify">;</span><span style=3D"color: #000;" cl=
ass=3D"styled-by-prettify"><br></span><span style=3D"color: #660;" class=3D=
"styled-by-prettify">}</span><span style=3D"color: #000;" class=3D"styled-b=
y-prettify"><br></span></div></code></div><br>And if macro-based version do=
es work, then this one will work without problems.<br><br><br></div><blockq=
uote class=3D"gmail_quote" style=3D"margin: 0;margin-left: 0.8ex;border-lef=
t: 1px #ccc solid;padding-left: 1ex;"><div>=C2=A0</div><blockquote class=3D=
"gmail_quote" style=3D"margin:0;margin-left:0.8ex;border-left:1px #ccc soli=
d;padding-left:1ex">
&gt;
<br>&gt; Also... how does `vector&lt;coroutine&gt;` make any kind of sense =
with regard
<br>&gt; to P0114? The type isn&#39;t type erased, so each coroutine has it=
s own
<br>&gt; type. Therefore, in order to put them in a homogeneous container l=
ike
<br>&gt; `vector`, you&#39;ll have to type-erase them. Which requires memor=
y allocation.
<br>=C2=A0&gt; At which point, your version gains /nothing/ over P0057.
<br>
<br>Same coroutines have same concrete types. For instance, with P0114 it=
=20
<br>may be:
<br>|
<br>struct concrete_coroutine
<br>{
<br>=C2=A0 =C2=A0 =C2=A0resumable auto r =3D expression;
<br>=C2=A0 =C2=A0 =C2=A0// ...
<br>};
<br>...
<br>make_unique&lt;concrete_<wbr>coroutine[]&gt;(N);
<br>|<br></blockquote><div><br>`auto` doesn&#39;t work that way. Non-static=
 data members cannot be `auto`. Normally I wouldn&#39;t care about a small =
issue like that, but it basically makes your code impossible.<br></div></bl=
ockquote><div><br><br>Such usage of auto is at p0114r0.pdf at page 11.<br>=
=C2=A0</div><blockquote class=3D"gmail_quote" style=3D"margin: 0;margin-lef=
t: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;"><div><br>Without `=
auto` NSDMI (and <a href=3D"http://www.open-std.org/JTC1/SC22/WG21/docs/pap=
ers/2014/n3897.html" target=3D"_blank" rel=3D"nofollow" onmousedown=3D"this=
..href=3D&#39;http://www.google.com/url?q\75http%3A%2F%2Fwww.open-std.org%2F=
JTC1%2FSC22%2FWG21%2Fdocs%2Fpapers%2F2014%2Fn3897.html\46sa\75D\46sntz\0751=
\46usg\75AFQjCNEJvBna1E4DHihTG8kJWVjTL7CIZw&#39;;return true;" onclick=3D"t=
his.href=3D&#39;http://www.google.com/url?q\75http%3A%2F%2Fwww.open-std.org=
%2FJTC1%2FSC22%2FWG21%2Fdocs%2Fpapers%2F2014%2Fn3897.html\46sa\75D\46sntz\0=
751\46usg\75AFQjCNEJvBna1E4DHihTG8kJWVjTL7CIZw&#39;;return true;">I wouldn&=
#39;t hold my breath on seeing it</a>), you can&#39;t store a resumable exp=
ression. So you can&#39;t make containers of them.<br><br>Unless you erase =
their types. So again, you&#39;ve gained <i>nothing</i>.<br><br>Your macro =
solution gets around this because it uses macros.<br></div><div>=C2=A0</div=
></blockquote><div><br>I showed two versions above - macro based version an=
d possible syntax with language support.<br>Do you have any concrete reason=
ing why it would be impossible without macros?<br>=C2=A0</div><blockquote c=
lass=3D"gmail_quote" style=3D"margin: 0;margin-left: 0.8ex;border-left: 1px=
 #ccc solid;padding-left: 1ex;"><blockquote class=3D"gmail_quote" style=3D"=
margin:0;margin-left:0.8ex;border-left:1px #ccc solid;padding-left:1ex">
Again, I am not talking specifically about P0114. Even P0057 can be=20
<br>changed to have concrete coroutine type.
<br></blockquote><div><br>I&#39;d be curious to see how, exactly.<br><br></=
div></blockquote><div><br>Currently it works like this:<br><div class=3D"pr=
ettyprint" style=3D"background-color: rgb(250, 250, 250); border-color: rgb=
(187, 187, 187); border-style: solid; border-width: 1px; word-wrap: break-w=
ord;"><code class=3D"prettyprint"><div class=3D"subprettyprint"><span style=
=3D"color: #008;" class=3D"styled-by-prettify">struct</span><span style=3D"=
color: #000;" class=3D"styled-by-prettify"> generator<br></span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">{</span><span style=3D"color=
: #000;" class=3D"styled-by-prettify"><br>=C2=A0 =C2=A0 =C2=A0</span><span =
style=3D"color: #660;" class=3D"styled-by-prettify">...</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"><br>=C2=A0 =C2=A0 =C2=A0coro=
utine_handle</span><span style=3D"color: #080;" class=3D"styled-by-prettify=
">&lt;promise_type&gt;</span><span style=3D"color: #000;" class=3D"styled-b=
y-prettify"> coro</span><span style=3D"color: #660;" class=3D"styled-by-pre=
ttify">;</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><b=
r></span><span style=3D"color: #660;" class=3D"styled-by-prettify">};</span=
><span style=3D"color: #000;" class=3D"styled-by-prettify"><br><br>generato=
r example_generator</span><span style=3D"color: #660;" class=3D"styled-by-p=
rettify">()</span><span style=3D"color: #000;" class=3D"styled-by-prettify"=
><br></span><span style=3D"color: #660;" class=3D"styled-by-prettify">{</sp=
an><span style=3D"color: #000;" class=3D"styled-by-prettify"><br>=C2=A0 =C2=
=A0 </span><span style=3D"color: #008;" class=3D"styled-by-prettify">yield<=
/span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><sp=
an style=3D"color: #066;" class=3D"styled-by-prettify">1</span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">;</span><span style=3D"color=
: #000;" class=3D"styled-by-prettify"><br></span><span style=3D"color: #660=
;" class=3D"styled-by-prettify">}</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"><br><br></span><span style=3D"color: #008;" class=
=3D"styled-by-prettify">int</span><span style=3D"color: #000;" class=3D"sty=
led-by-prettify"> main</span><span style=3D"color: #660;" class=3D"styled-b=
y-prettify">()</span><span style=3D"color: #000;" class=3D"styled-by-pretti=
fy"><br></span><span style=3D"color: #660;" class=3D"styled-by-prettify">{<=
/span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br>=C2=A0 =
=C2=A0 generator x </span><span style=3D"color: #660;" class=3D"styled-by-p=
rettify">=3D</span><span style=3D"color: #000;" class=3D"styled-by-prettify=
"> example_generator</span><span style=3D"color: #660;" class=3D"styled-by-=
prettify">();</span><span style=3D"color: #000;" class=3D"styled-by-prettif=
y"><br>=C2=A0 =C2=A0 x</span><span style=3D"color: #660;" class=3D"styled-b=
y-prettify">.</span><span style=3D"color: #000;" class=3D"styled-by-prettif=
y">move_next</span><span style=3D"color: #660;" class=3D"styled-by-prettify=
">();</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br>=
=C2=A0 =C2=A0 g</span><span style=3D"color: #660;" class=3D"styled-by-prett=
ify">.</span><span style=3D"color: #000;" class=3D"styled-by-prettify">curr=
ent_value</span><span style=3D"color: #660;" class=3D"styled-by-prettify">(=
);</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br></sp=
an><span style=3D"color: #660;" class=3D"styled-by-prettify">}</span><span =
style=3D"color: #000;" class=3D"styled-by-prettify"><br></span></div></code=
></div><br>With concrete coroutine type it could be something like this:<br=
><br><div class=3D"prettyprint" style=3D"background-color: rgb(250, 250, 25=
0); border-color: rgb(187, 187, 187); border-style: solid; border-width: 1p=
x; word-wrap: break-word;"><code class=3D"prettyprint"><div class=3D"subpre=
ttyprint"><span style=3D"color: #008;" class=3D"styled-by-prettify">templat=
e</span><span style=3D"color: #660;" class=3D"styled-by-prettify">&lt;</spa=
n><span style=3D"color: #008;" class=3D"styled-by-prettify">template</span>=
<span style=3D"color: #080;" class=3D"styled-by-prettify">&lt;typename&gt;<=
/span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><sp=
an style=3D"color: #008;" class=3D"styled-by-prettify">class</span><span st=
yle=3D"color: #000;" class=3D"styled-by-prettify"> coroutine_value</span><s=
pan style=3D"color: #660;" class=3D"styled-by-prettify">&gt;</span><span st=
yle=3D"color: #000;" class=3D"styled-by-prettify"><br></span><span style=3D=
"color: #008;" class=3D"styled-by-prettify">struct</span><span style=3D"col=
or: #000;" class=3D"styled-by-prettify"> generator<br></span><span style=3D=
"color: #660;" class=3D"styled-by-prettify">{</span><span style=3D"color: #=
000;" class=3D"styled-by-prettify"><br>=C2=A0 =C2=A0 =C2=A0</span><span sty=
le=3D"color: #660;" class=3D"styled-by-prettify">...</span><span style=3D"c=
olor: #000;" class=3D"styled-by-prettify"><br>=C2=A0 =C2=A0 =C2=A0coroutine=
_value</span><span style=3D"color: #080;" class=3D"styled-by-prettify">&lt;=
promise_type&gt;</span><span style=3D"color: #000;" class=3D"styled-by-pret=
tify"> coro</span><span style=3D"color: #660;" class=3D"styled-by-prettify"=
>;</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br></sp=
an><span style=3D"color: #660;" class=3D"styled-by-prettify">};</span><span=
 style=3D"color: #000;" class=3D"styled-by-prettify"><br><br>generator exam=
ple_generator</span><span style=3D"color: #660;" class=3D"styled-by-prettif=
y">()</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br><=
/span><span style=3D"color: #660;" class=3D"styled-by-prettify">{</span><sp=
an style=3D"color: #000;" class=3D"styled-by-prettify"><br>=C2=A0 =C2=A0 </=
span><span style=3D"color: #008;" class=3D"styled-by-prettify">yield</span>=
<span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span sty=
le=3D"color: #066;" class=3D"styled-by-prettify">1</span><span style=3D"col=
or: #660;" class=3D"styled-by-prettify">;</span><span style=3D"color: #000;=
" class=3D"styled-by-prettify"><br></span><span style=3D"color: #660;" clas=
s=3D"styled-by-prettify">}</span><span style=3D"color: #000;" class=3D"styl=
ed-by-prettify"><br></span><span style=3D"color: #800;" class=3D"styled-by-=
prettify">// example_generator is transformed to:</span><span style=3D"colo=
r: #000;" class=3D"styled-by-prettify"><br></span><span style=3D"color: #00=
8;" class=3D"styled-by-prettify">using</span><span style=3D"color: #000;" c=
lass=3D"styled-by-prettify"> example_generator </span><span style=3D"color:=
 #660;" class=3D"styled-by-prettify">=3D</span><span style=3D"color: #000;"=
 class=3D"styled-by-prettify"> generator</span><span style=3D"color: #660;"=
 class=3D"styled-by-prettify">&lt;</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"> synthesized_coroutine </span><span style=3D"color:=
 #660;" class=3D"styled-by-prettify">&gt;;</span><span style=3D"color: #000=
;" class=3D"styled-by-prettify"><br><br></span><span style=3D"color: #008;"=
 class=3D"styled-by-prettify">int</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"> main</span><span style=3D"color: #660;" class=3D"s=
tyled-by-prettify">()</span><span style=3D"color: #000;" class=3D"styled-by=
-prettify"><br></span><span style=3D"color: #660;" class=3D"styled-by-prett=
ify">{</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br>=
=C2=A0 =C2=A0 example_generator x</span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">{};</span><span style=3D"color: #000;" class=3D"sty=
led-by-prettify"><br>=C2=A0 =C2=A0 x</span><span style=3D"color: #660;" cla=
ss=3D"styled-by-prettify">.</span><span style=3D"color: #000;" class=3D"sty=
led-by-prettify">move_next</span><span style=3D"color: #660;" class=3D"styl=
ed-by-prettify">();</span><span style=3D"color: #000;" class=3D"styled-by-p=
rettify"><br>=C2=A0 =C2=A0 g</span><span style=3D"color: #660;" class=3D"st=
yled-by-prettify">.</span><span style=3D"color: #000;" class=3D"styled-by-p=
rettify">current_value</span><span style=3D"color: #660;" class=3D"styled-b=
y-prettify">();</span><span style=3D"color: #000;" class=3D"styled-by-prett=
ify"><br></span><span style=3D"color: #660;" class=3D"styled-by-prettify">}=
</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br></span=
></div></code></div><br>=C2=A0</div><blockquote class=3D"gmail_quote" style=
=3D"margin: 0;margin-left: 0.8ex;border-left: 1px #ccc solid;padding-left: =
1ex;"><div><br>If you want this done, then you&#39;re going to need to go t=
hrough the effort of designing the feature to work without type erasure. Th=
en you have to get someone to implement it.</div></blockquote><div><br>It c=
ould be implemented even with macros, to some extent. And I think macro-bas=
ed solution is enough for proof-of-concept.<br>=C2=A0</div><blockquote clas=
s=3D"gmail_quote" style=3D"margin: 0;margin-left: 0.8ex;border-left: 1px #c=
cc solid;padding-left: 1ex;"><div>Then, you can know whether it works just =
as well as P0057, whether it&#39;s equally easy to use, and how much of a p=
erformance advantage it gets.<br><br>If any.<br></div></blockquote><div><br=
>Of course it gives performance advantage, because does not impose extra ma=
ndatory allocation. <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_419_1957335235.1444847362387--
------=_Part_418_1074316711.1444847362386--

.
