Topic: Thumbs Up for "Coroutines TS Use Cases" and the ideas
Author: mihailnajdenov@gmail.com
Date: Fri, 22 Jun 2018 06:45:35 -0700 (PDT)
Raw View
------=_Part_11588_412533230.1529675135619
Content-Type: multipart/alternative;
boundary="----=_Part_11589_1524243949.1529675135620"
------=_Part_11589_1524243949.1529675135620
Content-Type: text/plain; charset="UTF-8"
I am very excited to see Coroutines TS Use Cases
<http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2018/p0973r0.pdf> and Core
Coroutines
<http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2018/p1063r0.pdf>
Ever since some CppCon presentations on how Coroutines can be used for non
async task, like unpacking 'expected' and 'optional' I was waiting for
someone to push these in similar direction.
More "basic" (less hooks, controlled allocation) , not so heavily
influenced by async (syntax, design goals), recognized as more fundamental
utility.
In any case, I read
<https://blog.jetbrains.com/clion/2018/06/iso-cpp-committee-rapperswil-2018-trip-report/>
the committee didn't like the syntax, so I have a suggestion(s).
First I like the idea of unpacking/unwrapping and that we should gat away
from "(a)waiting".
I think it will be nice to build on the idea of indirection and build
(syntactically) on the indirection operator ->
First variant is ~>, aka "soft indirection", this is, the indirection is
not immediate, but after unpack/some time (if async)
expected<int> SumOfSizes()
{
int result = 0;
for (int i = 0; i < kMaxIndex; ++i)
{
result += GetString(i)~>size(); //< unpack and call. Notice there is no
dot
}
return result;
}
I suggest to reuse the same op as "dereference"
optional<string> f();
string s = f()~>; //< "eject" the value
Second alternative is long arrow --> or "far indirection", again
non-immediate indirection, must unpack.
optional<string> f();
string s = f()-->; //< "eject"
The main benefit (or downside) is that it is clearly visible.
Thanks
--
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
To view this discussion on the web visit https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/e6d7c528-457d-46c5-b2d2-7254bda8b663%40isocpp.org.
------=_Part_11589_1524243949.1529675135620
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr"><div>I am very excited to see=C2=A0<a href=3D"http://www.o=
pen-std.org/jtc1/sc22/wg21/docs/papers/2018/p0973r0.pdf">Coroutines TS Use =
Cases</a> and <a href=3D"http://www.open-std.org/jtc1/sc22/wg21/docs/papers=
/2018/p1063r0.pdf">Core Coroutines=C2=A0</a></div><div><br></div><div>Ever =
since some CppCon presentations on how Coroutines can be used for non async=
task, like unpacking 'expected' and 'optional' I was waiti=
ng for someone to push these in similar direction.</div><div>More "bas=
ic" (less hooks, controlled allocation) , not so heavily influenced by=
async (syntax, design goals), recognized as more fundamental utility.=C2=
=A0</div><div><br></div><div>In any case, I <a href=3D"https://blog.jetbrai=
ns.com/clion/2018/06/iso-cpp-committee-rapperswil-2018-trip-report/">read</=
a> the committee didn't like the syntax, so I have a suggestion(s).</di=
v><div><br></div><div>First I like the idea of unpacking/unwrapping and tha=
t we should gat away from "(a)waiting".</div><div>I think it will=
be nice to build on the idea of indirection and build (syntactically) on t=
he indirection operator <font face=3D"courier new,monospace">-></font>=
=C2=A0</div><div><br></div><div>First variant is ~>, aka "soft indi=
rection", this is, the indirection is not immediate, but after unpack/=
some time (if async)</div><div><br></div><font face=3D"courier new,monospac=
e">expected<int> SumOfSizes()<br>{ <br>=C2=A0 int result =3D 0; <br>=
=C2=A0 for (int i =3D 0; i < kMaxIndex; ++i)<br>=C2=A0 { <br>=C2=A0 =
=C2=A0 result +=3D GetString(i)~>size(); //< unpack and call. Notice =
there is no dot<br>=C2=A0 } <br>=C2=A0 return result; <br></font><div><fo=
nt face=3D"courier new,monospace">}=C2=A0</font></div><div><br></div><div>I=
suggest to reuse the same op as "dereference"</div><div><br></di=
v><div><font face=3D"courier new,monospace">optional<string> f();=C2=
=A0</font></div><div><font face=3D"courier new,monospace">string s =3D f()~=
>; //< "eject" the value</font></div><div><font face=3D"cou=
rier new,monospace"><br></font></div><div><font face=3D"arial,sans-serif">S=
econd alternative is long arrow <font face=3D"courier new,monospace">-->=
</font> <span style=3D"text-align: left; color: rgb(34, 34, 34); text-trans=
form: none; text-indent: 0px; letter-spacing: normal; font-size: 13px; font=
-style: normal; font-variant: normal; font-weight: 400; text-decoration: no=
ne; word-spacing: 0px; display: inline !important; white-space: normal; orp=
hans: 2; float: none; -webkit-text-stroke-width: 0px; background-color: tra=
nsparent;">or "far indirection", again non-immediate indirection,=
must unpack.=C2=A0</span></font></div><div><font face=3D"arial,sans-serif"=
><span style=3D"text-align: left; color: rgb(34, 34, 34); text-transform: n=
one; text-indent: 0px; letter-spacing: normal; font-size: 13px; font-style:=
normal; font-variant: normal; font-weight: 400; text-decoration: none; wor=
d-spacing: 0px; display: inline !important; white-space: normal; orphans: 2=
; float: none; -webkit-text-stroke-width: 0px; background-color: transparen=
t;"><br></span></font></div><div><font face=3D"arial,sans-serif"><span styl=
e=3D"text-align: left; color: rgb(34, 34, 34); text-transform: none; text-i=
ndent: 0px; letter-spacing: normal; font-size: 13px; font-variant: normal; =
word-spacing: 0px; display: inline !important; white-space: normal; orphans=
: 2; float: none; -webkit-text-stroke-width: 0px; background-color: transpa=
rent;"><div style=3D"background-color: transparent; border-bottom-color: rg=
b(34, 34, 34); border-bottom-style: none; border-bottom-width: 0px; border-=
image-outset: 0; border-image-repeat: stretch; border-image-slice: 100%; bo=
rder-image-source: none; border-image-width: 1; border-left-color: rgb(34, =
34, 34); border-left-style: none; border-left-width: 0px; border-right-colo=
r: rgb(34, 34, 34); border-right-style: none; border-right-width: 0px; bord=
er-top-color: rgb(34, 34, 34); border-top-style: none; border-top-width: 0p=
x; color: rgb(34, 34, 34); font-family: &quot;Arial&quot;,&quot=
;Helvetica&quot;,sans-serif; font-size: 13px; font-style: normal; font-=
variant: normal; font-weight: 400; letter-spacing: normal; margin-bottom: 0=
px; margin-left: 0px; margin-right: 0px; margin-top: 0px; orphans: 2; paddi=
ng-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; te=
xt-align: left; text-decoration: none; text-indent: 0px; text-transform: no=
ne; -webkit-text-stroke-width: 0px; white-space: normal; word-spacing: 0px;=
"><font face=3D"courier new,monospace" style=3D"border-bottom-color: rgb(34=
, 34, 34); border-bottom-style: none; border-bottom-width: 0px; border-imag=
e-outset: 0; border-image-repeat: stretch; border-image-slice: 100%; border=
-image-source: none; border-image-width: 1; border-left-color: rgb(34, 34, =
34); border-left-style: none; border-left-width: 0px; border-right-color: r=
gb(34, 34, 34); border-right-style: none; border-right-width: 0px; border-t=
op-color: rgb(34, 34, 34); border-top-style: none; border-top-width: 0px; m=
argin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; pa=
dding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;=
">optional<string> f();=C2=A0</font></div><div style=3D"background-co=
lor: transparent; border-bottom-color: rgb(34, 34, 34); border-bottom-style=
: none; border-bottom-width: 0px; border-image-outset: 0; border-image-repe=
at: stretch; border-image-slice: 100%; border-image-source: none; border-im=
age-width: 1; border-left-color: rgb(34, 34, 34); border-left-style: none; =
border-left-width: 0px; border-right-color: rgb(34, 34, 34); border-right-s=
tyle: none; border-right-width: 0px; border-top-color: rgb(34, 34, 34); bor=
der-top-style: none; border-top-width: 0px; color: rgb(34, 34, 34); font-fa=
mily: &quot;Arial&quot;,&quot;Helvetica&quot;,sans-serif; f=
ont-size: 13px; font-style: normal; font-variant: normal; font-weight: 400;=
letter-spacing: normal; margin-bottom: 0px; margin-left: 0px; margin-right=
: 0px; margin-top: 0px; orphans: 2; padding-bottom: 0px; padding-left: 0px;=
padding-right: 0px; padding-top: 0px; text-align: left; text-decoration: n=
one; text-indent: 0px; text-transform: none; -webkit-text-stroke-width: 0px=
; white-space: normal; word-spacing: 0px;"><font face=3D"courier new,monosp=
ace" style=3D"border-bottom-color: rgb(34, 34, 34); border-bottom-style: no=
ne; border-bottom-width: 0px; border-image-outset: 0; border-image-repeat: =
stretch; border-image-slice: 100%; border-image-source: none; border-image-=
width: 1; border-left-color: rgb(34, 34, 34); border-left-style: none; bord=
er-left-width: 0px; border-right-color: rgb(34, 34, 34); border-right-style=
: none; border-right-width: 0px; border-top-color: rgb(34, 34, 34); border-=
top-style: none; border-top-width: 0px; margin-bottom: 0px; margin-left: 0p=
x; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0=
px; padding-right: 0px; padding-top: 0px;">string s =3D f()-->; //< &=
quot;eject"=C2=A0</font></div><div style=3D"background-color: transpar=
ent; border-bottom-color: rgb(34, 34, 34); border-bottom-style: none; borde=
r-bottom-width: 0px; border-image-outset: 0; border-image-repeat: stretch; =
border-image-slice: 100%; border-image-source: none; border-image-width: 1;=
border-left-color: rgb(34, 34, 34); border-left-style: none; border-left-w=
idth: 0px; border-right-color: rgb(34, 34, 34); border-right-style: none; b=
order-right-width: 0px; border-top-color: rgb(34, 34, 34); border-top-style=
: none; border-top-width: 0px; color: rgb(34, 34, 34); font-family: &qu=
ot;Arial&quot;,&quot;Helvetica&quot;,sans-serif; font-size: 13p=
x; font-style: normal; font-variant: normal; font-weight: 400; letter-spaci=
ng: normal; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin=
-top: 0px; orphans: 2; padding-bottom: 0px; padding-left: 0px; padding-righ=
t: 0px; padding-top: 0px; text-align: left; text-decoration: none; text-ind=
ent: 0px; text-transform: none; -webkit-text-stroke-width: 0px; white-space=
: normal; word-spacing: 0px;"><font face=3D"courier new,monospace" style=3D=
"border-bottom-color: rgb(34, 34, 34); border-bottom-style: none; border-bo=
ttom-width: 0px; border-image-outset: 0; border-image-repeat: stretch; bord=
er-image-slice: 100%; border-image-source: none; border-image-width: 1; bor=
der-left-color: rgb(34, 34, 34); border-left-style: none; border-left-width=
: 0px; border-right-color: rgb(34, 34, 34); border-right-style: none; borde=
r-right-width: 0px; border-top-color: rgb(34, 34, 34); border-top-style: no=
ne; border-top-width: 0px; margin-bottom: 0px; margin-left: 0px; margin-rig=
ht: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-r=
ight: 0px; padding-top: 0px;"><br></font></div><div style=3D"background-col=
or: transparent; border-bottom-color: rgb(34, 34, 34); border-bottom-style:=
none; border-bottom-width: 0px; border-image-outset: 0; border-image-repea=
t: stretch; border-image-slice: 100%; border-image-source: none; border-ima=
ge-width: 1; border-left-color: rgb(34, 34, 34); border-left-style: none; b=
order-left-width: 0px; border-right-color: rgb(34, 34, 34); border-right-st=
yle: none; border-right-width: 0px; border-top-color: rgb(34, 34, 34); bord=
er-top-style: none; border-top-width: 0px; color: rgb(34, 34, 34); font-fam=
ily: &quot;Arial&quot;,&quot;Helvetica&quot;,sans-serif; fo=
nt-size: 13px; font-style: normal; font-variant: normal; font-weight: 400; =
letter-spacing: normal; margin-bottom: 0px; margin-left: 0px; margin-right:=
0px; margin-top: 0px; orphans: 2; padding-bottom: 0px; padding-left: 0px; =
padding-right: 0px; padding-top: 0px; text-align: left; text-decoration: no=
ne; text-indent: 0px; text-transform: none; -webkit-text-stroke-width: 0px;=
white-space: normal; word-spacing: 0px;"><font style=3D"border-bottom-colo=
r: rgb(34, 34, 34); border-bottom-style: none; border-bottom-width: 0px; bo=
rder-image-outset: 0; border-image-repeat: stretch; border-image-slice: 100=
%; border-image-source: none; border-image-width: 1; border-left-color: rgb=
(34, 34, 34); border-left-style: none; border-left-width: 0px; border-right=
-color: rgb(34, 34, 34); border-right-style: none; border-right-width: 0px;=
border-top-color: rgb(34, 34, 34); border-top-style: none; border-top-widt=
h: 0px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top=
: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-=
top: 0px;">The main benefit (or downside) is that it is clearly visible.=C2=
=A0</font><font style=3D"border-bottom-color: rgb(34, 34, 34); border-botto=
m-style: none; border-bottom-width: 0px; border-image-outset: 0; border-ima=
ge-repeat: stretch; border-image-slice: 100%; border-image-source: none; bo=
rder-image-width: 1; border-left-color: rgb(34, 34, 34); border-left-style:=
none; border-left-width: 0px; border-right-color: rgb(34, 34, 34); border-=
right-style: none; border-right-width: 0px; border-top-color: rgb(34, 34, 3=
4); border-top-style: none; border-top-width: 0px; margin-bottom: 0px; marg=
in-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padd=
ing-left: 0px; padding-right: 0px; padding-top: 0px;"><br></font></div><div=
style=3D"background-color: transparent; border-bottom-color: rgb(34, 34, 3=
4); border-bottom-style: none; border-bottom-width: 0px; border-image-outse=
t: 0; border-image-repeat: stretch; border-image-slice: 100%; border-image-=
source: none; border-image-width: 1; border-left-color: rgb(34, 34, 34); bo=
rder-left-style: none; border-left-width: 0px; border-right-color: rgb(34, =
34, 34); border-right-style: none; border-right-width: 0px; border-top-colo=
r: rgb(34, 34, 34); border-top-style: none; border-top-width: 0px; color: r=
gb(34, 34, 34); font-family: &quot;Arial&quot;,&quot;Helvetica&=
amp;quot;,sans-serif; font-size: 13px; font-style: normal; font-variant: no=
rmal; font-weight: 400; letter-spacing: normal; margin-bottom: 0px; margin-=
left: 0px; margin-right: 0px; margin-top: 0px; orphans: 2; padding-bottom: =
0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-align: l=
eft; text-decoration: none; text-indent: 0px; text-transform: none; -webkit=
-text-stroke-width: 0px; white-space: normal; word-spacing: 0px;"><br></div=
><div>Thanks</div></span></font></div></div>
<p></p>
-- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals" group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+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 />
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/e6d7c528-457d-46c5-b2d2-7254bda8b663%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/e6d7c528-457d-46c5-b2d2-7254bda8b663=
%40isocpp.org</a>.<br />
------=_Part_11589_1524243949.1529675135620--
------=_Part_11588_412533230.1529675135619--
.