Topic: Readability improvement: all function keywords go on
Author: Dimitrij Mijoski <dim.mj.p@gmail.com>
Date: Fri, 10 Aug 2018 05:51:13 -0700 (PDT)
Raw View
------=_Part_718_1025639071.1533905473407
Content-Type: multipart/alternative;
boundary="----=_Part_719_796571686.1533905473407"
------=_Part_719_796571686.1533905473407
Content-Type: text/plain; charset="UTF-8"
This proposal is strictly about syntax, its goal is to get better
readability.
In C++11 there was an excellent improvements with this regard with auto
variables, trailing return function syntax and with using. But since then,
we kinda forgot on this aspect. These syntax features gave left-to-right
reading, i.e. the code reads the same way one would read it on English.
One concern I have is the syntax for function declaration. Currently we
have:
left keywords Type function_name(Parameter list) right keywords;
auto left keywords function_name(Parameter list) right keywords -> Type;
left keywords auto function_name(Parameter list) right keywords -> Type;
Left keywords are: static, virtual and constexpr.
Right are: const, &, &&, virtual, override, final, noexcept.
I'm mostly concerned about constexpr getting sprayed all over the standard
library. On cppreference.com you often see:
Type func(Param p1, Param p2, Param p3); (until C++17)
constexpr Type func(Param p1, Param p2, Param p3); (since C++20)
Even the documentation is harder to read now. I'd like to see the "one
true" function definition syntax to go like this:
auto function_name(Param p1, Param p2, Param p3) all keywords here [[attributes
here]] -> Type;
--
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/d1b97e79-b166-422e-8a87-fc6d22b5da32%40isocpp.org.
------=_Part_719_796571686.1533905473407
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr">This proposal is strictly about syntax, its goal is to get=
better readability.<br><br>In C++11 there was an excellent improvements wi=
th this regard with auto variables, trailing return function syntax and wit=
h using. But since then, we kinda forgot on this aspect. These syntax featu=
res gave left-to-right reading, i.e. the code reads the same way one would =
read it on English.<br><br>One concern I have is the syntax for function de=
claration. Currently we have:<br><br><div style=3D"background-color: rgb(25=
0, 250, 250); border-color: rgb(187, 187, 187); border-style: solid; border=
-width: 1px; overflow-wrap: break-word;" class=3D"prettyprint"><code class=
=3D"prettyprint"><div class=3D"subprettyprint"><span style=3D"color: #000;"=
class=3D"styled-by-prettify">left keywords </span><span style=3D"color: #6=
06;" class=3D"styled-by-prettify">Type</span><span style=3D"color: #000;" c=
lass=3D"styled-by-prettify"> function_name</span><span style=3D"color: #660=
;" class=3D"styled-by-prettify">(</span><span style=3D"color: #606;" class=
=3D"styled-by-prettify">Parameter</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"> list</span><span style=3D"color: #660;" class=3D"s=
tyled-by-prettify">)</span><span style=3D"color: #000;" class=3D"styled-by-=
prettify"> right keywords</span><span style=3D"color: #660;" class=3D"style=
d-by-prettify">;</span><span style=3D"color: #000;" class=3D"styled-by-pret=
tify"><br></span><span style=3D"color: #008;" class=3D"styled-by-prettify">=
auto</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> left =
keywords function_name</span><span style=3D"color: #660;" class=3D"styled-b=
y-prettify">(</span><span style=3D"color: #606;" class=3D"styled-by-prettif=
y">Parameter</span><span style=3D"color: #000;" class=3D"styled-by-prettify=
"> list</span><span style=3D"color: #660;" class=3D"styled-by-prettify">)</=
span><span style=3D"color: #000;" class=3D"styled-by-prettify"> right keywo=
rds </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: #606;" class=3D"styled-by-prettify">Type</span><span sty=
le=3D"color: #660;" class=3D"styled-by-prettify">;</span><span style=3D"col=
or: #000;" class=3D"styled-by-prettify"><br>left keywords </span><span styl=
e=3D"color: #008;" class=3D"styled-by-prettify">auto</span><span style=3D"c=
olor: #000;" class=3D"styled-by-prettify"> function_name</span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">(</span><span style=3D"color=
: #606;" class=3D"styled-by-prettify">Parameter</span><span style=3D"color:=
#000;" class=3D"styled-by-prettify"> list</span><span style=3D"color: #660=
;" class=3D"styled-by-prettify">)</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"> right keywords </span><span style=3D"color: #660;"=
class=3D"styled-by-prettify">-></span><span style=3D"color: #000;" clas=
s=3D"styled-by-prettify"> </span><span style=3D"color: #606;" class=3D"styl=
ed-by-prettify">Type</span><span style=3D"color: #660;" class=3D"styled-by-=
prettify">;</span></div></code></div><div><br></div><div>Left keywords are:=
static, virtual and constexpr.</div>Right are: const, &, &&, v=
irtual, override, final, noexcept.<br><br>I'm mostly concerned about co=
nstexpr getting sprayed all over the standard library. On cppreference.com =
you often see:<br><br><div style=3D"background-color: rgb(250, 250, 250); b=
order-color: rgb(187, 187, 187); border-style: solid; border-width: 1px; ov=
erflow-wrap: break-word;" class=3D"prettyprint"><code class=3D"prettyprint"=
><div class=3D"subprettyprint"><span style=3D"color: #606;" class=3D"styled=
-by-prettify">Type</span><span style=3D"color: #000;" class=3D"styled-by-pr=
ettify"> func</span><span style=3D"color: #660;" class=3D"styled-by-prettif=
y">(</span><span style=3D"color: #606;" class=3D"styled-by-prettify">Param<=
/span><span style=3D"color: #000;" class=3D"styled-by-prettify"> p1</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: #606;" class=3D"styled-by-prettify">Param</span><span style=3D"color: #0=
00;" class=3D"styled-by-prettify"> p2</span><span style=3D"color: #660;" cl=
ass=3D"styled-by-prettify">,</span><span style=3D"color: #000;" class=3D"st=
yled-by-prettify"> </span><span style=3D"color: #606;" class=3D"styled-by-p=
rettify">Param</span><span style=3D"color: #000;" class=3D"styled-by-pretti=
fy"> p3</span><span style=3D"color: #660;" class=3D"styled-by-prettify">);<=
/span><span style=3D"color: #000;" class=3D"styled-by-prettify"> =C2=A0 =C2=
=A0 =C2=A0 =C2=A0 =C2=A0 </span><span style=3D"color: #660;" class=3D"style=
d-by-prettify">(</span><span style=3D"color: #008;" class=3D"styled-by-pret=
tify">until</span><span style=3D"color: #000;" class=3D"styled-by-prettify"=
> C</span><span style=3D"color: #660;" class=3D"styled-by-prettify">++</spa=
n><span style=3D"color: #066;" class=3D"styled-by-prettify">17</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:=
#008;" class=3D"styled-by-prettify">constexpr</span><span style=3D"color: =
#000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #606;" cl=
ass=3D"styled-by-prettify">Type</span><span style=3D"color: #000;" class=3D=
"styled-by-prettify"> func</span><span style=3D"color: #660;" class=3D"styl=
ed-by-prettify">(</span><span style=3D"color: #606;" class=3D"styled-by-pre=
ttify">Param</span><span style=3D"color: #000;" class=3D"styled-by-prettify=
"> p1</span><span style=3D"color: #660;" class=3D"styled-by-prettify">,</sp=
an><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span =
style=3D"color: #606;" class=3D"styled-by-prettify">Param</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"> p2</span><span style=3D"col=
or: #660;" class=3D"styled-by-prettify">,</span><span style=3D"color: #000;=
" class=3D"styled-by-prettify"> </span><span style=3D"color: #606;" class=
=3D"styled-by-prettify">Param</span><span style=3D"color: #000;" class=3D"s=
tyled-by-prettify"> p3</span><span style=3D"color: #660;" class=3D"styled-b=
y-prettify">);</span><span style=3D"color: #000;" class=3D"styled-by-pretti=
fy"> </span><span style=3D"color: #660;" class=3D"styled-by-prettify">(</sp=
an><span style=3D"color: #000;" class=3D"styled-by-prettify">since C</span>=
<span style=3D"color: #660;" class=3D"styled-by-prettify">++</span><span st=
yle=3D"color: #066;" class=3D"styled-by-prettify">20</span><span style=3D"c=
olor: #660;" class=3D"styled-by-prettify">)</span></div></code></div><br>Ev=
en the documentation is harder to read now. I'd like to see the "o=
ne true" function definition syntax to go like this:<br><br><div style=
=3D"background-color: rgb(250, 250, 250); border-color: rgb(187, 187, 187);=
border-style: solid; border-width: 1px; overflow-wrap: break-word;" class=
=3D"prettyprint"><code class=3D"prettyprint"><div class=3D"subprettyprint">=
<span style=3D"color: #008;" class=3D"styled-by-prettify">auto</span><span =
style=3D"color: #000;" class=3D"styled-by-prettify"> function_name</span><s=
pan style=3D"color: #660;" class=3D"styled-by-prettify">(</span><span style=
=3D"color: #606;" class=3D"styled-by-prettify">Param</span><span style=3D"c=
olor: #000;" class=3D"styled-by-prettify"> p1</span><span style=3D"color: #=
660;" class=3D"styled-by-prettify">,</span><span style=3D"color: #000;" cla=
ss=3D"styled-by-prettify"> </span><span style=3D"color: #606;" class=3D"sty=
led-by-prettify">Param</span><span style=3D"color: #000;" class=3D"styled-b=
y-prettify"> p2</span><span style=3D"color: #660;" class=3D"styled-by-prett=
ify">,</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </s=
pan><span style=3D"color: #606;" class=3D"styled-by-prettify">Param</span><=
span style=3D"color: #000;" class=3D"styled-by-prettify"> p3</span><span st=
yle=3D"color: #660;" class=3D"styled-by-prettify">)</span><span style=3D"co=
lor: #000;" class=3D"styled-by-prettify"> all keywords here </span><span st=
yle=3D"color: #660;" class=3D"styled-by-prettify">[[</span><span style=3D"c=
olor: #000;" class=3D"styled-by-prettify">attributes here</span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">]]</span><span style=3D"colo=
r: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #660;"=
class=3D"styled-by-prettify">-></span><span style=3D"color: #000;" clas=
s=3D"styled-by-prettify"> </span><span style=3D"color: #606;" class=3D"styl=
ed-by-prettify">Type</span><span style=3D"color: #660;" class=3D"styled-by-=
prettify">;</span></div></code></div><br></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/d1b97e79-b166-422e-8a87-fc6d22b5da32%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/d1b97e79-b166-422e-8a87-fc6d22b5da32=
%40isocpp.org</a>.<br />
------=_Part_719_796571686.1533905473407--
------=_Part_718_1025639071.1533905473407--
.