Topic: Readability improvement: types go on the right side
Author: Dimitrij Mijoski <dim.mj.p@gmail.com>
Date: Fri, 10 Aug 2018 06:20:48 -0700 (PDT)
Raw View
------=_Part_794_162298396.1533907248888
Content-Type: multipart/alternative;
boundary="----=_Part_795_783619087.1533907248889"
------=_Part_795_783619087.1533907248889
Content-Type: text/plain; charset="UTF-8"
In C++11 and onward we can declare a variable with and without auto.
Type x;
auto x = Type();
In English we would read both as: Let x be a variable of type Type. It is
obvious that the declaration with auto is easier to read. We can't do this
with member variables or with function parameters. I'd like a future C++ to
have types on the right side everywhere.
We can take example from Pascal where first comes the name, then colon and
then the type. Same syntax is adopted in ActionScript, Rust, Haxe, and
possibly many others.
class my_type {
private:
auto x: int;
auto y: std::string;
public:
auto function(a: size_t, b: vector<size_t>) -> float;
};
Or, maybe avoid the colon syntax for members, use the same as locals.
class my_type {
private:
auto x = int();
auto y = std::string();
public:
auto function(a: size_t, b: std::vector<size_t>) -> float;
};
With this second syntax we will reuse the same rules for initialization as
for locals with auto keyword. In this example, value initialization is done
instead of default initialization.
--
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/d1e4945a-8605-4c11-99c9-5e8b30ce1186%40isocpp.org.
------=_Part_795_783619087.1533907248889
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr">In C++11 and onward we can declare a variable with and wit=
hout auto.<br><br><div style=3D"background-color: rgb(250, 250, 250); borde=
r-color: rgb(187, 187, 187); border-style: solid; border-width: 1px; overfl=
ow-wrap: break-word;" class=3D"prettyprint"><code class=3D"prettyprint"><di=
v class=3D"subprettyprint"><span style=3D"color: #606;" class=3D"styled-by-=
prettify">Type</span><span style=3D"color: #000;" class=3D"styled-by-pretti=
fy"> x</span><span style=3D"color: #660;" class=3D"styled-by-prettify">;</s=
pan><span style=3D"color: #000;" class=3D"styled-by-prettify"><br></span><s=
pan style=3D"color: #008;" class=3D"styled-by-prettify">auto</span><span st=
yle=3D"color: #000;" class=3D"styled-by-prettify"> x </span><span style=3D"=
color: #660;" class=3D"styled-by-prettify">=3D</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: #660;" class=3D=
"styled-by-prettify">();</span></div></code></div><br>In English we would r=
ead both as: Let x be a variable of type Type. It is obvious that the decla=
ration with auto is easier to read. We can't do this with member variab=
les or with function parameters. I'd like a future C++ to have types on=
the right side everywhere.<br><br>We can take example from Pascal where fi=
rst comes the name, then colon and then the type. Same syntax is adopted in=
ActionScript, Rust, Haxe, and possibly many others.<br><br><div style=3D"b=
ackground-color: rgb(250, 250, 250); border-color: rgb(187, 187, 187); bord=
er-style: solid; border-width: 1px; overflow-wrap: break-word;" class=3D"pr=
ettyprint"><code class=3D"prettyprint"><div class=3D"subprettyprint"><span =
style=3D"color: #008;" class=3D"styled-by-prettify">class</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"> my_type </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">private</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: #008;" c=
lass=3D"styled-by-prettify">auto</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"> x</span><span style=3D"color: #660;" class=3D"styl=
ed-by-prettify">:</span><span style=3D"color: #000;" class=3D"styled-by-pre=
ttify"> </span><span style=3D"color: #008;" class=3D"styled-by-prettify">in=
t</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: #008;" class=3D"styled-by-prettify">auto</span=
><span style=3D"color: #000;" class=3D"styled-by-prettify"> y</span><span s=
tyle=3D"color: #660;" class=3D"styled-by-prettify">:</span><span style=3D"c=
olor: #000;" class=3D"styled-by-prettify"> std</span><span style=3D"color: =
#660;" class=3D"styled-by-prettify">::</span><span style=3D"color: #008;" c=
lass=3D"styled-by-prettify">string</span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">;</span><span style=3D"color: #000;" class=3D"style=
d-by-prettify"><br><br></span><span style=3D"color: #008;" class=3D"styled-=
by-prettify">public</span><span style=3D"color: #660;" class=3D"styled-by-p=
rettify">:</span><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-pr=
ettify">auto</span><span style=3D"color: #000;" class=3D"styled-by-prettify=
"> </span><span style=3D"color: #008;" class=3D"styled-by-prettify">functio=
n</span><span style=3D"color: #660;" class=3D"styled-by-prettify">(</span><=
span style=3D"color: #000;" class=3D"styled-by-prettify">a</span><span styl=
e=3D"color: #660;" class=3D"styled-by-prettify">:</span><span style=3D"colo=
r: #000;" class=3D"styled-by-prettify"> size_t</span><span style=3D"color: =
#660;" class=3D"styled-by-prettify">,</span><span style=3D"color: #000;" cl=
ass=3D"styled-by-prettify"> b</span><span style=3D"color: #660;" class=3D"s=
tyled-by-prettify">:</span><span style=3D"color: #000;" class=3D"styled-by-=
prettify"> vector</span><span style=3D"color: #080;" class=3D"styled-by-pre=
ttify"><size_t></span><span style=3D"color: #660;" class=3D"styled-by=
-prettify">)</span><span style=3D"color: #000;" class=3D"styled-by-prettify=
"> </span><span style=3D"color: #660;" class=3D"styled-by-prettify">-></=
span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><spa=
n style=3D"color: #008;" class=3D"styled-by-prettify">float</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></span><span style=3D"color: #6=
60;" class=3D"styled-by-prettify">};</span></div></code></div><br><br><br>O=
r, maybe avoid the colon syntax for members, use the same as locals.<br><di=
v 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"subprettyp=
rint"><span style=3D"color: #000;" class=3D"styled-by-prettify"><br></span>=
<span style=3D"color: #008;" class=3D"styled-by-prettify">class</span><span=
style=3D"color: #000;" class=3D"styled-by-prettify"> my_type </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">private</span><span style=3D"color: #6=
60;" class=3D"styled-by-prettify">:</span><span style=3D"color: #000;" clas=
s=3D"styled-by-prettify"><br>=C2=A0 =C2=A0 </span><span style=3D"color: #00=
8;" class=3D"styled-by-prettify">auto</span><span style=3D"color: #000;" cl=
ass=3D"styled-by-prettify"> x </span><span style=3D"color: #660;" class=3D"=
styled-by-prettify">=3D</span><span style=3D"color: #000;" class=3D"styled-=
by-prettify"> </span><span style=3D"color: #008;" class=3D"styled-by-pretti=
fy">int</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: #008;" class=3D"styled-by-prettify">au=
to</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> y </spa=
n><span style=3D"color: #660;" class=3D"styled-by-prettify">=3D</span><span=
style=3D"color: #000;" class=3D"styled-by-prettify"> std</span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">::</span><span style=3D"colo=
r: #008;" class=3D"styled-by-prettify">string</span><span style=3D"color: #=
660;" class=3D"styled-by-prettify">();</span><span style=3D"color: #000;" c=
lass=3D"styled-by-prettify"><br><br></span><span style=3D"color: #008;" cla=
ss=3D"styled-by-prettify">public</span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">:</span><span style=3D"color: #000;" class=3D"style=
d-by-prettify"><br>=C2=A0 =C2=A0 </span><span style=3D"color: #008;" class=
=3D"styled-by-prettify">auto</span><span style=3D"color: #000;" class=3D"st=
yled-by-prettify"> </span><span style=3D"color: #008;" class=3D"styled-by-p=
rettify">function</span><span style=3D"color: #660;" class=3D"styled-by-pre=
ttify">(</span><span style=3D"color: #000;" class=3D"styled-by-prettify">a<=
/span><span style=3D"color: #660;" class=3D"styled-by-prettify">:</span><sp=
an style=3D"color: #000;" class=3D"styled-by-prettify"> size_t</span><span =
style=3D"color: #660;" class=3D"styled-by-prettify">,</span><span style=3D"=
color: #000;" class=3D"styled-by-prettify"> b</span><span style=3D"color: #=
660;" class=3D"styled-by-prettify">:</span><span style=3D"color: #000;" cla=
ss=3D"styled-by-prettify"> std</span><span style=3D"color: #660;" class=3D"=
styled-by-prettify">::</span><span style=3D"color: #000;" class=3D"styled-b=
y-prettify">vector</span><span style=3D"color: #080;" class=3D"styled-by-pr=
ettify"><size_t></span><span style=3D"color: #660;" class=3D"styled-b=
y-prettify">)</span><span style=3D"color: #000;" class=3D"styled-by-prettif=
y"> </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: #008;" class=3D"styled-by-prettify">float</span><span st=
yle=3D"color: #660;" class=3D"styled-by-prettify">;</span><span style=3D"co=
lor: #000;" class=3D"styled-by-prettify"><br></span><span style=3D"color: #=
660;" class=3D"styled-by-prettify">};</span></div></code></div><br><br>With=
this second syntax we will reuse the same rules for initialization as for =
locals with auto keyword. In this example, value initialization is done ins=
tead of default initialization.<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/d1e4945a-8605-4c11-99c9-5e8b30ce1186%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/d1e4945a-8605-4c11-99c9-5e8b30ce1186=
%40isocpp.org</a>.<br />
------=_Part_795_783619087.1533907248889--
------=_Part_794_162298396.1533907248888--
.
Author: Nicol Bolas <jmckesson@gmail.com>
Date: Fri, 10 Aug 2018 06:43:54 -0700 (PDT)
Raw View
------=_Part_767_2109635498.1533908634303
Content-Type: multipart/alternative;
boundary="----=_Part_768_357153968.1533908634304"
------=_Part_768_357153968.1533908634304
Content-Type: text/plain; charset="UTF-8"
On Friday, August 10, 2018 at 9:20:49 AM UTC-4, Dimitrij Mijoski wrote:
>
> In C++11 and onward we can declare a variable with and without auto.
>
> Type x;
> auto x = Type();
>
> In English we would read both as: Let x be a variable of type Type. It is
> obvious that the declaration with auto is easier to read.
>
Is it? I find "Let there be a variable of type `Type` called `x`" works
just as well.
We can't do this with member variables or with function parameters. I'd
> like a future C++ to have types on the right side everywhere.
>
So, you're suggesting that we use precious syntax for notation. This won't
increase the capabilities of any C++ program; it simply changes how things
are declared.
Yeah, that's not really worth the cost.
--
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/71cf7691-0c85-46b2-9a85-46a9b4b57e9d%40isocpp.org.
------=_Part_768_357153968.1533908634304
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr"><br><br>On Friday, August 10, 2018 at 9:20:49 AM UTC-4, Di=
mitrij Mijoski wrote:<blockquote class=3D"gmail_quote" style=3D"margin: 0;m=
argin-left: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;"><div dir=
=3D"ltr">In C++11 and onward we can declare a variable with and without aut=
o.<br><br><div style=3D"background-color:rgb(250,250,250);border-color:rgb(=
187,187,187);border-style:solid;border-width:1px"><code><div><span style=3D=
"color:#606">Type</span><span style=3D"color:#000"> x</span><span style=3D"=
color:#660">;</span><span style=3D"color:#000"><br></span><span style=3D"co=
lor:#008">auto</span><span style=3D"color:#000"> x </span><span style=3D"co=
lor:#660">=3D</span><span style=3D"color:#000"> </span><span style=3D"color=
:#606">Type</span><span style=3D"color:#660">();</span></div></code></div><=
br>In English we would read both as: Let x be a variable of type Type. It i=
s obvious that the declaration with auto is easier to read.</div></blockquo=
te><div><br></div><div>Is it? I find "Let there be a variable of type =
`Type` called `x`" works just as well.<br></div><div><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 dir=3D"ltr">We can't do this=
with member variables or with function parameters. I'd like a future C=
++ to have types on the right side everywhere.<br></div></blockquote><div><=
br></div><div>So, you're suggesting that we use precious syntax for not=
ation. This won't increase the capabilities of any C++ program; it simp=
ly changes how things are declared.</div><div><br></div><div>Yeah, that'=
;s not really worth the cost.</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/71cf7691-0c85-46b2-9a85-46a9b4b57e9d%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/71cf7691-0c85-46b2-9a85-46a9b4b57e9d=
%40isocpp.org</a>.<br />
------=_Part_768_357153968.1533908634304--
------=_Part_767_2109635498.1533908634303--
.
Author: Dimitrij Mijoski <dim.mj.p@gmail.com>
Date: Fri, 10 Aug 2018 07:25:32 -0700 (PDT)
Raw View
------=_Part_706_423036990.1533911132496
Content-Type: multipart/alternative;
boundary="----=_Part_707_570712097.1533911132496"
------=_Part_707_570712097.1533911132496
Content-Type: text/plain; charset="UTF-8"
On Friday, August 10, 2018 at 3:43:54 PM UTC+2, Nicol Bolas wrote:
>
>
> Is it? I find "Let there be a variable of type `Type` called `x`" works
> just as well.
>
Please open various math textbooks or textbooks on algorithms or similar
materials and just see how common is the expression "Let x be a
varaible...". That is a reason why many popular programming languages
adopted a keyword let, not just syntax with type after variable name. Even
C++ adopted this, but not completely.
> So, you're suggesting that we use precious syntax for notation. This won't
> increase the capabilities of any C++ program; it simply changes how things
> are declared.
>
> Yeah, that's not really worth the cost.
>
>
Yes I'm suggesting exactly that, and it is worth the effort. Not all
changes have to be stuffing features and making the language write-only.
Now, I'm going to ignore your further comments because you are the regular
troll around here.
--
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/fc28bd62-14b3-46d3-add3-ed10dafd3830%40isocpp.org.
------=_Part_707_570712097.1533911132496
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr">On Friday, August 10, 2018 at 3:43:54 PM UTC+2, Nicol Bola=
s wrote:<blockquote class=3D"gmail_quote" style=3D"margin: 0;margin-left: 0=
..8ex;border-left: 1px #ccc solid;padding-left: 1ex;"><div dir=3D"ltr"><br><=
div>Is it? I find "Let there be a variable of type `Type` called `x`&q=
uot; works just as well.<br></div></div></blockquote><div><br></div><div>Pl=
ease open various math textbooks or textbooks on algorithms or similar mate=
rials and just see how common is the expression "Let x be a varaible..=
..". That is a reason why many popular programming languages adopted a =
keyword let, not just syntax with type after variable name. Even C++ adopte=
d this, but not completely.<br></div><div>=C2=A0</div><div><br></div><block=
quote class=3D"gmail_quote" style=3D"margin: 0;margin-left: 0.8ex;border-le=
ft: 1px #ccc solid;padding-left: 1ex;"><div dir=3D"ltr"><div></div><div><br=
></div><div>So, you're suggesting that we use precious syntax for notat=
ion. This won't increase the capabilities of any C++ program; it simply=
changes how things are declared.</div><div><br></div><div>Yeah, that's=
not really worth the cost.</div><br></div></blockquote><div><br></div><div=
>Yes I'm suggesting exactly that, and it is worth the effort. Not all c=
hanges have to be stuffing features and making the language write-only.</di=
v><div><br></div><div>Now, I'm going to ignore your further comments be=
cause you are the regular troll around here.<br></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/fc28bd62-14b3-46d3-add3-ed10dafd3830%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/fc28bd62-14b3-46d3-add3-ed10dafd3830=
%40isocpp.org</a>.<br />
------=_Part_707_570712097.1533911132496--
------=_Part_706_423036990.1533911132496--
.
Author: Nicol Bolas <jmckesson@gmail.com>
Date: Fri, 10 Aug 2018 07:36:15 -0700 (PDT)
Raw View
------=_Part_835_1590633775.1533911775509
Content-Type: multipart/alternative;
boundary="----=_Part_836_1411239134.1533911775509"
------=_Part_836_1411239134.1533911775509
Content-Type: text/plain; charset="UTF-8"
On Friday, August 10, 2018 at 10:25:32 AM UTC-4, Dimitrij Mijoski wrote:
>
> On Friday, August 10, 2018 at 3:43:54 PM UTC+2, Nicol Bolas wrote:
>>
>>
>> Is it? I find "Let there be a variable of type `Type` called `x`" works
>> just as well.
>>
>
> Please open various math textbooks or textbooks on algorithms or similar
> materials and just see how common is the expression "Let x be a
> varaible...". That is a reason why many popular programming languages
> adopted a keyword let, not just syntax with type after variable name. Even
> C++ adopted this, but not completely.
>
No, it didn't. Variable type deduction was not added to make this kind of
syntax possible. It was added to allow people to write variables of types
that were too long to bother naming. Yes, it did make this syntax possible,
but that was not the purpose of the feature.
It should also be noted that C++'s type deduction syntax still isn't "Let x
be a variable". After all, you can do `decltype(auto) x = ...`, which says
something very different about that variable relative to than `auto x =
....`.
So, you're suggesting that we use precious syntax for notation. This won't
>> increase the capabilities of any C++ program; it simply changes how things
>> are declared.
>>
>> Yeah, that's not really worth the cost.
>>
>>
> Yes I'm suggesting exactly that, and it is worth the effort. Not all
> changes have to be stuffing features and making the language write-only.
>
I fail to see how the order of variables with regard to their types is
"making the language write-only".
--
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/94ef2e07-a476-4fde-aeeb-89c86d2cd5b3%40isocpp.org.
------=_Part_836_1411239134.1533911775509
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr">On Friday, August 10, 2018 at 10:25:32 AM UTC-4, Dimitrij =
Mijoski wrote:<blockquote class=3D"gmail_quote" style=3D"margin: 0;margin-l=
eft: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;"><div dir=3D"ltr"=
>On Friday, August 10, 2018 at 3:43:54 PM UTC+2, Nicol Bolas wrote:<blockqu=
ote class=3D"gmail_quote" style=3D"margin:0;margin-left:0.8ex;border-left:1=
px #ccc solid;padding-left:1ex"><div dir=3D"ltr"><br><div>Is it? I find &qu=
ot;Let there be a variable of type `Type` called `x`" works just as we=
ll.<br></div></div></blockquote><div><br></div><div>Please open various mat=
h textbooks or textbooks on algorithms or similar materials and just see ho=
w common is the expression "Let x be a varaible...". That is a re=
ason why many popular programming languages adopted a keyword let, not just=
syntax with type after variable name. Even C++ adopted this, but not compl=
etely.<br></div></div></blockquote><div><br></div><div>No, it didn't. V=
ariable type deduction was not added to make this kind of syntax possible. =
It was added to allow people to write variables of types that were too long=
to bother naming. Yes, it did make this syntax possible, but that was not =
the purpose of the feature.</div><div><br></div><div>It should also be note=
d that C++'s type deduction syntax still isn't "Let x be a var=
iable". After all, you can do `decltype(auto) x =3D ...`, which says s=
omething very different about that variable relative to than `auto x =3D ..=
..`.</div><div></div><div><br></div><div></div><blockquote class=3D"gmail_qu=
ote" style=3D"margin: 0;margin-left: 0.8ex;border-left: 1px #ccc solid;padd=
ing-left: 1ex;"><div dir=3D"ltr"><div></div><div></div><blockquote class=3D=
"gmail_quote" style=3D"margin:0;margin-left:0.8ex;border-left:1px #ccc soli=
d;padding-left:1ex"><div dir=3D"ltr"><div></div><div></div><div>So, you'=
;re suggesting that we use precious syntax for notation. This won't inc=
rease the capabilities of any C++ program; it simply changes how things are=
declared.</div><div><br></div><div>Yeah, that's not really worth the c=
ost.</div><br></div></blockquote><div><br></div><div>Yes I'm suggesting=
exactly that, and it is worth the effort. Not all changes have to be stuff=
ing features and making the language write-only.</div></div></blockquote><d=
iv><br></div><div>I fail to see how the order of variables with regard to t=
heir types is "making the language write-only".</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/94ef2e07-a476-4fde-aeeb-89c86d2cd5b3%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/94ef2e07-a476-4fde-aeeb-89c86d2cd5b3=
%40isocpp.org</a>.<br />
------=_Part_836_1411239134.1533911775509--
------=_Part_835_1590633775.1533911775509--
.
Author: j c <james.a.cooper@gmail.com>
Date: Fri, 10 Aug 2018 16:22:01 +0100
Raw View
--000000000000dcd4430573164e7b
Content-Type: text/plain; charset="UTF-8"
On Fri, Aug 10, 2018 at 2:20 PM Dimitrij Mijoski <dim.mj.p@gmail.com> wrote:
> In C++11 and onward we can declare a variable with and without auto.
>
> Type x;
> auto x = Type();
>
> In English we would read both as: Let x be a variable of type Type. It is
> obvious that the declaration with auto is easier to read. We can't do this
> with member variables or with function parameters. I'd like a future C++ to
> have types on the right side everywhere.
>
> We can take example from Pascal where first comes the name, then colon and
> then the type. Same syntax is adopted in ActionScript, Rust, Haxe, and
> possibly many others.
>
> class my_type {
> private:
> auto x: int;
> auto y: std::string;
>
> public:
> auto function(a: size_t, b: vector<size_t>) -> float;
> };
>
>
>
> Or, maybe avoid the colon syntax for members, use the same as locals.
>
> class my_type {
> private:
> auto x = int();
> auto y = std::string();
>
> public:
> auto function(a: size_t, b: std::vector<size_t>) -> float;
> };
>
>
> With this second syntax we will reuse the same rules for initialization as
> for locals with auto keyword. In this example, value initialization is done
> instead of default initialization.
>
How would you initialise a member variable that is a reference?
class C
{
auto& x = ???;
}
--
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/CAFQaeCC%2BVWB8C3Bc1LxhxkctX-VoFnTR5DCg_KX-DTEfFijG5g%40mail.gmail.com.
--000000000000dcd4430573164e7b
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr"><br><div class=3D"gmail_quote"><div dir=3D"ltr">On Fri, Au=
g 10, 2018 at 2:20 PM Dimitrij Mijoski <<a href=3D"mailto:dim.mj.p@gmail=
..com">dim.mj.p@gmail.com</a>> wrote:<br></div><blockquote class=3D"gmail=
_quote" style=3D"margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:=
1ex"><div dir=3D"ltr">In C++11 and onward we can declare a variable with an=
d without auto.<br><br><div class=3D"m_-7043680470528922963prettyprint" sty=
le=3D"background-color:rgb(250,250,250);border-color:rgb(187,187,187);borde=
r-style:solid;border-width:1px"><code class=3D"m_-7043680470528922963pretty=
print"><div class=3D"m_-7043680470528922963subprettyprint"><span class=3D"m=
_-7043680470528922963styled-by-prettify" style=3D"color:#606">Type</span><s=
pan class=3D"m_-7043680470528922963styled-by-prettify" style=3D"color:#000"=
> x</span><span class=3D"m_-7043680470528922963styled-by-prettify" style=3D=
"color:#660">;</span><span class=3D"m_-7043680470528922963styled-by-prettif=
y" style=3D"color:#000"><br></span><span class=3D"m_-7043680470528922963sty=
led-by-prettify" style=3D"color:#008">auto</span><span class=3D"m_-70436804=
70528922963styled-by-prettify" style=3D"color:#000"> x </span><span class=
=3D"m_-7043680470528922963styled-by-prettify" style=3D"color:#660">=3D</spa=
n><span class=3D"m_-7043680470528922963styled-by-prettify" style=3D"color:#=
000"> </span><span class=3D"m_-7043680470528922963styled-by-prettify" style=
=3D"color:#606">Type</span><span class=3D"m_-7043680470528922963styled-by-p=
rettify" style=3D"color:#660">();</span></div></code></div><br>In English w=
e would read both as: Let x be a variable of type Type. It is obvious that =
the declaration with auto is easier to read. We can't do this with memb=
er variables or with function parameters. I'd like a future C++ to have=
types on the right side everywhere.<br><br>We can take example from Pascal=
where first comes the name, then colon and then the type. Same syntax is a=
dopted in ActionScript, Rust, Haxe, and possibly many others.<br><br><div c=
lass=3D"m_-7043680470528922963prettyprint" style=3D"background-color:rgb(25=
0,250,250);border-color:rgb(187,187,187);border-style:solid;border-width:1p=
x"><code class=3D"m_-7043680470528922963prettyprint"><div class=3D"m_-70436=
80470528922963subprettyprint"><span class=3D"m_-7043680470528922963styled-b=
y-prettify" style=3D"color:#008">class</span><span class=3D"m_-704368047052=
8922963styled-by-prettify" style=3D"color:#000"> my_type </span><span class=
=3D"m_-7043680470528922963styled-by-prettify" style=3D"color:#660">{</span>=
<span class=3D"m_-7043680470528922963styled-by-prettify" style=3D"color:#00=
0"><br></span><span class=3D"m_-7043680470528922963styled-by-prettify" styl=
e=3D"color:#008">private</span><span class=3D"m_-7043680470528922963styled-=
by-prettify" style=3D"color:#660">:</span><span class=3D"m_-704368047052892=
2963styled-by-prettify" style=3D"color:#000"><br>=C2=A0 =C2=A0 </span><span=
class=3D"m_-7043680470528922963styled-by-prettify" style=3D"color:#008">au=
to</span><span class=3D"m_-7043680470528922963styled-by-prettify" style=3D"=
color:#000"> x</span><span class=3D"m_-7043680470528922963styled-by-prettif=
y" style=3D"color:#660">:</span><span class=3D"m_-7043680470528922963styled=
-by-prettify" style=3D"color:#000"> </span><span class=3D"m_-70436804705289=
22963styled-by-prettify" style=3D"color:#008">int</span><span class=3D"m_-7=
043680470528922963styled-by-prettify" style=3D"color:#660">;</span><span cl=
ass=3D"m_-7043680470528922963styled-by-prettify" style=3D"color:#000"><br>=
=C2=A0 =C2=A0 </span><span class=3D"m_-7043680470528922963styled-by-prettif=
y" style=3D"color:#008">auto</span><span class=3D"m_-7043680470528922963sty=
led-by-prettify" style=3D"color:#000"> y</span><span class=3D"m_-7043680470=
528922963styled-by-prettify" style=3D"color:#660">:</span><span class=3D"m_=
-7043680470528922963styled-by-prettify" style=3D"color:#000"> std</span><sp=
an class=3D"m_-7043680470528922963styled-by-prettify" style=3D"color:#660">=
::</span><span class=3D"m_-7043680470528922963styled-by-prettify" style=3D"=
color:#008">string</span><span class=3D"m_-7043680470528922963styled-by-pre=
ttify" style=3D"color:#660">;</span><span class=3D"m_-7043680470528922963st=
yled-by-prettify" style=3D"color:#000"><br><br></span><span class=3D"m_-704=
3680470528922963styled-by-prettify" style=3D"color:#008">public</span><span=
class=3D"m_-7043680470528922963styled-by-prettify" style=3D"color:#660">:<=
/span><span class=3D"m_-7043680470528922963styled-by-prettify" style=3D"col=
or:#000"><br>=C2=A0 =C2=A0 </span><span class=3D"m_-7043680470528922963styl=
ed-by-prettify" style=3D"color:#008">auto</span><span class=3D"m_-704368047=
0528922963styled-by-prettify" style=3D"color:#000"> </span><span class=3D"m=
_-7043680470528922963styled-by-prettify" style=3D"color:#008">function</spa=
n><span class=3D"m_-7043680470528922963styled-by-prettify" style=3D"color:#=
660">(</span><span class=3D"m_-7043680470528922963styled-by-prettify" style=
=3D"color:#000">a</span><span class=3D"m_-7043680470528922963styled-by-pret=
tify" style=3D"color:#660">:</span><span class=3D"m_-7043680470528922963sty=
led-by-prettify" style=3D"color:#000"> size_t</span><span class=3D"m_-70436=
80470528922963styled-by-prettify" style=3D"color:#660">,</span><span class=
=3D"m_-7043680470528922963styled-by-prettify" style=3D"color:#000"> b</span=
><span class=3D"m_-7043680470528922963styled-by-prettify" style=3D"color:#6=
60">:</span><span class=3D"m_-7043680470528922963styled-by-prettify" style=
=3D"color:#000"> vector</span><span class=3D"m_-7043680470528922963styled-b=
y-prettify" style=3D"color:#080"><size_t></span><span class=3D"m_-704=
3680470528922963styled-by-prettify" style=3D"color:#660">)</span><span clas=
s=3D"m_-7043680470528922963styled-by-prettify" style=3D"color:#000"> </span=
><span class=3D"m_-7043680470528922963styled-by-prettify" style=3D"color:#6=
60">-></span><span class=3D"m_-7043680470528922963styled-by-prettify" st=
yle=3D"color:#000"> </span><span class=3D"m_-7043680470528922963styled-by-p=
rettify" style=3D"color:#008">float</span><span class=3D"m_-704368047052892=
2963styled-by-prettify" style=3D"color:#660">;</span><span class=3D"m_-7043=
680470528922963styled-by-prettify" style=3D"color:#000"><br></span><span cl=
ass=3D"m_-7043680470528922963styled-by-prettify" style=3D"color:#660">};</s=
pan></div></code></div><br><br><br>Or, maybe avoid the colon syntax for mem=
bers, use the same as locals.<br><div class=3D"m_-7043680470528922963pretty=
print" style=3D"background-color:rgb(250,250,250);border-color:rgb(187,187,=
187);border-style:solid;border-width:1px"><code class=3D"m_-704368047052892=
2963prettyprint"><div class=3D"m_-7043680470528922963subprettyprint"><span =
class=3D"m_-7043680470528922963styled-by-prettify" style=3D"color:#000"><br=
></span><span class=3D"m_-7043680470528922963styled-by-prettify" style=3D"c=
olor:#008">class</span><span class=3D"m_-7043680470528922963styled-by-prett=
ify" style=3D"color:#000"> my_type </span><span class=3D"m_-704368047052892=
2963styled-by-prettify" style=3D"color:#660">{</span><span class=3D"m_-7043=
680470528922963styled-by-prettify" style=3D"color:#000"><br></span><span cl=
ass=3D"m_-7043680470528922963styled-by-prettify" style=3D"color:#008">priva=
te</span><span class=3D"m_-7043680470528922963styled-by-prettify" style=3D"=
color:#660">:</span><span class=3D"m_-7043680470528922963styled-by-prettify=
" style=3D"color:#000"><br>=C2=A0 =C2=A0 </span><span class=3D"m_-704368047=
0528922963styled-by-prettify" style=3D"color:#008">auto</span><span class=
=3D"m_-7043680470528922963styled-by-prettify" style=3D"color:#000"> x </spa=
n><span class=3D"m_-7043680470528922963styled-by-prettify" style=3D"color:#=
660">=3D</span><span class=3D"m_-7043680470528922963styled-by-prettify" sty=
le=3D"color:#000"> </span><span class=3D"m_-7043680470528922963styled-by-pr=
ettify" style=3D"color:#008">int</span><span class=3D"m_-704368047052892296=
3styled-by-prettify" style=3D"color:#660">();</span><span class=3D"m_-70436=
80470528922963styled-by-prettify" style=3D"color:#000"><br>=C2=A0 =C2=A0 </=
span><span class=3D"m_-7043680470528922963styled-by-prettify" style=3D"colo=
r:#008">auto</span><span class=3D"m_-7043680470528922963styled-by-prettify"=
style=3D"color:#000"> y </span><span class=3D"m_-7043680470528922963styled=
-by-prettify" style=3D"color:#660">=3D</span><span class=3D"m_-704368047052=
8922963styled-by-prettify" style=3D"color:#000"> std</span><span class=3D"m=
_-7043680470528922963styled-by-prettify" style=3D"color:#660">::</span><spa=
n class=3D"m_-7043680470528922963styled-by-prettify" style=3D"color:#008">s=
tring</span><span class=3D"m_-7043680470528922963styled-by-prettify" style=
=3D"color:#660">();</span><span class=3D"m_-7043680470528922963styled-by-pr=
ettify" style=3D"color:#000"><br><br></span><span class=3D"m_-7043680470528=
922963styled-by-prettify" style=3D"color:#008">public</span><span class=3D"=
m_-7043680470528922963styled-by-prettify" style=3D"color:#660">:</span><spa=
n class=3D"m_-7043680470528922963styled-by-prettify" style=3D"color:#000"><=
br>=C2=A0 =C2=A0 </span><span class=3D"m_-7043680470528922963styled-by-pret=
tify" style=3D"color:#008">auto</span><span class=3D"m_-7043680470528922963=
styled-by-prettify" style=3D"color:#000"> </span><span class=3D"m_-70436804=
70528922963styled-by-prettify" style=3D"color:#008">function</span><span cl=
ass=3D"m_-7043680470528922963styled-by-prettify" style=3D"color:#660">(</sp=
an><span class=3D"m_-7043680470528922963styled-by-prettify" style=3D"color:=
#000">a</span><span class=3D"m_-7043680470528922963styled-by-prettify" styl=
e=3D"color:#660">:</span><span class=3D"m_-7043680470528922963styled-by-pre=
ttify" style=3D"color:#000"> size_t</span><span class=3D"m_-704368047052892=
2963styled-by-prettify" style=3D"color:#660">,</span><span class=3D"m_-7043=
680470528922963styled-by-prettify" style=3D"color:#000"> b</span><span clas=
s=3D"m_-7043680470528922963styled-by-prettify" style=3D"color:#660">:</span=
><span class=3D"m_-7043680470528922963styled-by-prettify" style=3D"color:#0=
00"> std</span><span class=3D"m_-7043680470528922963styled-by-prettify" sty=
le=3D"color:#660">::</span><span class=3D"m_-7043680470528922963styled-by-p=
rettify" style=3D"color:#000">vector</span><span class=3D"m_-70436804705289=
22963styled-by-prettify" style=3D"color:#080"><size_t></span><span cl=
ass=3D"m_-7043680470528922963styled-by-prettify" style=3D"color:#660">)</sp=
an><span class=3D"m_-7043680470528922963styled-by-prettify" style=3D"color:=
#000"> </span><span class=3D"m_-7043680470528922963styled-by-prettify" styl=
e=3D"color:#660">-></span><span class=3D"m_-7043680470528922963styled-by=
-prettify" style=3D"color:#000"> </span><span class=3D"m_-70436804705289229=
63styled-by-prettify" style=3D"color:#008">float</span><span class=3D"m_-70=
43680470528922963styled-by-prettify" style=3D"color:#660">;</span><span cla=
ss=3D"m_-7043680470528922963styled-by-prettify" style=3D"color:#000"><br></=
span><span class=3D"m_-7043680470528922963styled-by-prettify" style=3D"colo=
r:#660">};</span></div></code></div><br><br>With this second syntax we will=
reuse the same rules for initialization as for locals with auto keyword. I=
n this example, value initialization is done instead of default initializat=
ion.<br></div></blockquote><div><br></div><div>How would you initialise a m=
ember variable that is a reference?</div><div><br></div><div>class C</div><=
div>{</div><div>=C2=A0=C2=A0 auto& x =3D ???;</div><div>}=C2=A0</div></=
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/CAFQaeCC%2BVWB8C3Bc1LxhxkctX-VoFnTR5D=
Cg_KX-DTEfFijG5g%40mail.gmail.com?utm_medium=3Demail&utm_source=3Dfooter">h=
ttps://groups.google.com/a/isocpp.org/d/msgid/std-proposals/CAFQaeCC%2BVWB8=
C3Bc1LxhxkctX-VoFnTR5DCg_KX-DTEfFijG5g%40mail.gmail.com</a>.<br />
--000000000000dcd4430573164e7b--
.
Author: Dimitrij Mijoski <dim.mj.p@gmail.com>
Date: Sat, 11 Aug 2018 11:03:08 -0700 (PDT)
Raw View
------=_Part_1125_1666228917.1534010588902
Content-Type: multipart/alternative;
boundary="----=_Part_1126_668936910.1534010588903"
------=_Part_1126_668936910.1534010588903
Content-Type: text/plain; charset="UTF-8"
On Friday, August 10, 2018 at 5:22:15 PM UTC+2, j c wrote:
>
> How would you initialise a member variable that is a reference?
>
> class C
> {
> auto& x = ???;
> }
>
References are indeed problematic. We may attempt at this
class C {
auto& x = Type();
}
which to the current rules for auto is equivalent to this
class C {
Type& x = Type();
}
And this is invalid code.
We may change the rules for auto for data member references only to infer
the type, not to act as default member initializer
<https://en.cppreference.com/w/cpp/language/data_members#Member_initialization>,
but that is just breaking consistency. Maybe just stick to the colon
notation.
class C {
auto x: 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/90253fc7-868f-45c2-88cb-d601f991acad%40isocpp.org.
------=_Part_1126_668936910.1534010588903
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr">On Friday, August 10, 2018 at 5:22:15 PM UTC+2, j c wrote:=
<br><blockquote class=3D"gmail_quote" style=3D"margin: 0;margin-left: 0.8ex=
;border-left: 1px #ccc solid;padding-left: 1ex;"><div dir=3D"ltr"><div clas=
s=3D"gmail_quote"><div><br></div><div>How would you initialise a member var=
iable that is a reference?</div><div><br></div><div>class C</div><div>{</di=
v><div>=C2=A0=C2=A0 auto& x =3D ???;</div><div>}=C2=A0</div></div></div=
></blockquote><div><br></div><br><div>References are indeed problematic. We=
may attempt at this</div><div><br></div><div><div style=3D"background-colo=
r: rgb(250, 250, 250); border-color: rgb(187, 187, 187); border-style: soli=
d; border-width: 1px; overflow-wrap: break-word;" class=3D"prettyprint"><co=
de class=3D"prettyprint"><div class=3D"subprettyprint"><div><div style=3D"b=
ackground-color: rgb(250, 250, 250); border-color: rgb(187, 187, 187); bord=
er-style: solid; border-width: 1px; overflow-wrap: break-word;" class=3D"pr=
ettyprint"><code class=3D"prettyprint"><div class=3D"subprettyprint"><span =
style=3D"color: #008;" class=3D"styled-by-prettify">class</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"> C </span><span style=3D"col=
or: #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"colo=
r: #008;" class=3D"styled-by-prettify">auto</span><span style=3D"color: #66=
0;" class=3D"styled-by-prettify">&</span><span style=3D"color: #000;" c=
lass=3D"styled-by-prettify"> x </span><span style=3D"color: #660;" class=3D=
"styled-by-prettify">=3D</span><span style=3D"color: #000;" class=3D"styled=
-by-prettify"> </span><span style=3D"color: #606;" class=3D"styled-by-prett=
ify">Type</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></div><span style=3D"color: #000;" class=3D"styled-by-prettify"></sp=
an></div></code></div></div><div>which to the current rules for auto is equ=
ivalent to this</div><div><br></div><div><div style=3D"background-color: rg=
b(250, 250, 250); border-color: rgb(187, 187, 187); border-style: solid; bo=
rder-width: 1px; overflow-wrap: break-word;" class=3D"prettyprint"><div><di=
v 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"subprettyp=
rint"><span style=3D"color: #008;" class=3D"styled-by-prettify">class</span=
><span style=3D"color: #000;" class=3D"styled-by-prettify"> C </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 Type</span><sp=
an style=3D"color: #660;" class=3D"styled-by-prettify">&</span><span st=
yle=3D"color: #000;" class=3D"styled-by-prettify"> x </span><span style=3D"=
color: #660;" class=3D"styled-by-prettify">=3D</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: #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-pr=
ettify">}</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><=
br></span></div></code></div></div></div><br>And this is invalid code.</div=
><div><br></div><div>We may change the rules for auto for data member refer=
ences only to infer the type, not to act as <a href=3D"https://en.cpprefere=
nce.com/w/cpp/language/data_members#Member_initialization">default member i=
nitializer</a>, but that is just breaking consistency. Maybe just stick to =
the colon notation.</div><div><br></div><div><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"><cod=
e class=3D"prettyprint"><div class=3D"subprettyprint"><code class=3D"pretty=
print"><div style=3D"background-color: rgb(250, 250, 250); border-color: rg=
b(187, 187, 187); border-style: solid; border-width: 1px; overflow-wrap: br=
eak-word;" class=3D"prettyprint"><div><div style=3D"background-color: rgb(2=
50, 250, 250); border-color: rgb(187, 187, 187); border-style: solid; borde=
r-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">class</span><span style=3D"color: #000;" clas=
s=3D"styled-by-prettify"> C </span><span style=3D"color: #660;" class=3D"st=
yled-by-prettify">{</span><span style=3D"color: #000;" class=3D"styled-by-p=
rettify"><br>=C2=A0 =C2=A0 auto</span><span style=3D"color: #000;" class=3D=
"styled-by-prettify"> x: Type&</span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">;</span><span style=3D"color: #000;" class=3D"style=
d-by-prettify"><br></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></div></code></div></div></div></code><span style=3D"color: #660=
;" class=3D"styled-by-prettify"></span></div></code></div><br><br></div><di=
v><br><br></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/90253fc7-868f-45c2-88cb-d601f991acad%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/90253fc7-868f-45c2-88cb-d601f991acad=
%40isocpp.org</a>.<br />
------=_Part_1126_668936910.1534010588903--
------=_Part_1125_1666228917.1534010588902--
.
Author: cppljevans@gmail.com
Date: Sun, 12 Aug 2018 13:53:22 -0700 (PDT)
Raw View
------=_Part_1177_1943463406.1534107202154
Content-Type: multipart/alternative;
boundary="----=_Part_1178_658081876.1534107202155"
------=_Part_1178_658081876.1534107202155
Content-Type: text/plain; charset="UTF-8"
On Friday, August 10, 2018 at 8:20:49 AM UTC-5, Dimitrij Mijoski wrote:
>
> In C++11 and onward we can declare a variable with and without auto.
>
> Type x;
> auto x = Type();
>
> In English we would read both as: Let x be a variable of type Type. It is
> obvious that the declaration with auto is easier to read. We can't do this
> with member variables or with function parameters. I'd like a future C++ to
> have types on the right side everywhere.
>
> We can take example from Pascal where first comes the name, then colon and
> then the type. Same syntax is adopted in ActionScript, Rust, Haxe, and
> possibly many others.
>
> class my_type {
> private:
> auto x: int;
> auto y: std::string;
>
> public:
> auto function(a: size_t, b: vector<size_t>) -> float;
> };
>
>
>
> Or, maybe avoid the colon syntax for members, use the same as locals.
>
> class my_type {
> private:
> auto x = int();
> auto y = std::string();
>
> public:
> auto function(a: size_t, b: std::vector<size_t>) -> float;
> };
>
>
> With this second syntax we will reuse the same rules for initialization as
> for locals with auto keyword. In this example, value initialization is done
> instead of default initialization.
>
How would arrays be declared? Maybe:
auto arr : [n_1][n_2]->result_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/a1a46362-5b3c-4611-801a-427ea6f9cac9%40isocpp.org.
------=_Part_1178_658081876.1534107202155
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr"><br><br>On Friday, August 10, 2018 at 8:20:49 AM UTC-5, Di=
mitrij Mijoski wrote:<blockquote class=3D"gmail_quote" style=3D"margin: 0;m=
argin-left: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;"><div dir=
=3D"ltr">In C++11 and onward we can declare a variable with and without aut=
o.<br><br><div style=3D"background-color:rgb(250,250,250);border-color:rgb(=
187,187,187);border-style:solid;border-width:1px"><code><div><span style=3D=
"color:#606">Type</span><span style=3D"color:#000"> x</span><span style=3D"=
color:#660">;</span><span style=3D"color:#000"><br></span><span style=3D"co=
lor:#008">auto</span><span style=3D"color:#000"> x </span><span style=3D"co=
lor:#660">=3D</span><span style=3D"color:#000"> </span><span style=3D"color=
:#606">Type</span><span style=3D"color:#660">();</span></div></code></div><=
br>In English we would read both as: Let x be a variable of type Type. It i=
s obvious that the declaration with auto is easier to read. We can't do=
this with member variables or with function parameters. I'd like a fut=
ure C++ to have types on the right side everywhere.<br><br>We can take exam=
ple from Pascal where first comes the name, then colon and then the type. S=
ame syntax is adopted in ActionScript, Rust, Haxe, and possibly many others=
..<br><br><div style=3D"background-color:rgb(250,250,250);border-color:rgb(1=
87,187,187);border-style:solid;border-width:1px"><code><div><span style=3D"=
color:#008">class</span><span style=3D"color:#000"> my_type </span><span st=
yle=3D"color:#660">{</span><span style=3D"color:#000"><br></span><span styl=
e=3D"color:#008">private</span><span style=3D"color:#660">:</span><span sty=
le=3D"color:#000"><br>=C2=A0 =C2=A0 </span><span style=3D"color:#008">auto<=
/span><span style=3D"color:#000"> x</span><span style=3D"color:#660">:</spa=
n><span style=3D"color:#000"> </span><span style=3D"color:#008">int</span><=
span style=3D"color:#660">;</span><span style=3D"color:#000"><br>=C2=A0 =C2=
=A0 </span><span style=3D"color:#008">auto</span><span style=3D"color:#000"=
> y</span><span style=3D"color:#660">:</span><span style=3D"color:#000"> st=
d</span><span style=3D"color:#660">::</span><span style=3D"color:#008">stri=
ng</span><span style=3D"color:#660">;</span><span style=3D"color:#000"><br>=
<br></span><span style=3D"color:#008">public</span><span style=3D"color:#66=
0">:</span><span style=3D"color:#000"><br>=C2=A0 =C2=A0 </span><span style=
=3D"color:#008">auto</span><span style=3D"color:#000"> </span><span style=
=3D"color:#008">function</span><span style=3D"color:#660">(</span><span sty=
le=3D"color:#000">a</span><span style=3D"color:#660">:</span><span style=3D=
"color:#000"> size_t</span><span style=3D"color:#660">,</span><span style=
=3D"color:#000"> b</span><span style=3D"color:#660">:</span><span style=3D"=
color:#000"> vector</span><span style=3D"color:#080"><size_t></span><=
span style=3D"color:#660">)</span><span style=3D"color:#000"> </span><span =
style=3D"color:#660">-></span><span style=3D"color:#000"> </span><span s=
tyle=3D"color:#008">float</span><span style=3D"color:#660">;</span><span st=
yle=3D"color:#000"><br></span><span style=3D"color:#660">};</span></div></c=
ode></div><br><br><br>Or, maybe avoid the colon syntax for members, use the=
same as locals.<br><div style=3D"background-color:rgb(250,250,250);border-=
color:rgb(187,187,187);border-style:solid;border-width:1px"><code><div><spa=
n style=3D"color:#000"><br></span><span style=3D"color:#008">class</span><s=
pan style=3D"color:#000"> my_type </span><span style=3D"color:#660">{</span=
><span style=3D"color:#000"><br></span><span style=3D"color:#008">private</=
span><span style=3D"color:#660">:</span><span style=3D"color:#000"><br>=C2=
=A0 =C2=A0 </span><span style=3D"color:#008">auto</span><span style=3D"colo=
r:#000"> x </span><span style=3D"color:#660">=3D</span><span style=3D"color=
:#000"> </span><span style=3D"color:#008">int</span><span style=3D"color:#6=
60">();</span><span style=3D"color:#000"><br>=C2=A0 =C2=A0 </span><span sty=
le=3D"color:#008">auto</span><span style=3D"color:#000"> y </span><span sty=
le=3D"color:#660">=3D</span><span style=3D"color:#000"> std</span><span sty=
le=3D"color:#660">::</span><span style=3D"color:#008">string</span><span st=
yle=3D"color:#660">();</span><span style=3D"color:#000"><br><br></span><spa=
n style=3D"color:#008">public</span><span style=3D"color:#660">:</span><spa=
n style=3D"color:#000"><br>=C2=A0 =C2=A0 </span><span style=3D"color:#008">=
auto</span><span style=3D"color:#000"> </span><span style=3D"color:#008">fu=
nction</span><span style=3D"color:#660">(</span><span style=3D"color:#000">=
a</span><span style=3D"color:#660">:</span><span style=3D"color:#000"> size=
_t</span><span style=3D"color:#660">,</span><span style=3D"color:#000"> b</=
span><span style=3D"color:#660">:</span><span style=3D"color:#000"> std</sp=
an><span style=3D"color:#660">::</span><span style=3D"color:#000">vector</s=
pan><span style=3D"color:#080"><size_t></span><span style=3D"color:#6=
60">)</span><span style=3D"color:#000"> </span><span style=3D"color:#660">-=
></span><span style=3D"color:#000"> </span><span style=3D"color:#008">fl=
oat</span><span style=3D"color:#660">;</span><span style=3D"color:#000"><br=
></span><span style=3D"color:#660">};</span></div></code></div><br><br>With=
this second syntax we will reuse the same rules for initialization as for =
locals with auto keyword. In this example, value initialization is done ins=
tead of default initialization.<br></div></blockquote><div><br></div><div>H=
ow would arrays be declared? Maybe:<br></div><div><br></div><div><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"> arr </span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">:</span><span style=3D"color=
: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #660;" =
class=3D"styled-by-prettify">[</span><span style=3D"color: #000;" class=3D"=
styled-by-prettify">n_1</span><span style=3D"color: #660;" class=3D"styled-=
by-prettify">][</span><span style=3D"color: #000;" class=3D"styled-by-prett=
ify">n_2</span><span style=3D"color: #660;" class=3D"styled-by-prettify">]-=
></span><span style=3D"color: #000;" class=3D"styled-by-prettify">result=
_type</span><span style=3D"color: #660;" class=3D"styled-by-prettify">;</sp=
an><span style=3D"color: #000;" class=3D"styled-by-prettify"><br></span></d=
iv></code></div>?<br> <br></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/a1a46362-5b3c-4611-801a-427ea6f9cac9%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/a1a46362-5b3c-4611-801a-427ea6f9cac9=
%40isocpp.org</a>.<br />
------=_Part_1178_658081876.1534107202155--
------=_Part_1177_1943463406.1534107202154--
.
Author: Dimitrij Mijoski <dim.mj.p@gmail.com>
Date: Sun, 12 Aug 2018 14:06:07 -0700 (PDT)
Raw View
------=_Part_1268_677895816.1534107967686
Content-Type: multipart/alternative;
boundary="----=_Part_1269_1727749694.1534107967687"
------=_Part_1269_1727749694.1534107967687
Content-Type: text/plain; charset="UTF-8"
On Sunday, August 12, 2018 at 10:53:22 PM UTC+2, cpplj...@gmail.com wrote:
>
>
> How would arrays be declared? Maybe:
>
> auto arr : [n_1][n_2]->result_type;
> ?
>
>
No, why complicate like that?
What about:
auto arr: int[3];
--
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/519c2f35-c6b3-461f-89be-87ccd00f8be5%40isocpp.org.
------=_Part_1269_1727749694.1534107967687
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr">On Sunday, August 12, 2018 at 10:53:22 PM UTC+2, cpplj...@=
gmail.com wrote:<blockquote class=3D"gmail_quote" style=3D"margin: 0;margin=
-left: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;"><div dir=3D"lt=
r"><br><div>How would arrays be declared? Maybe:<br></div><div><br></div><d=
iv><div style=3D"background-color:rgb(250,250,250);border-color:rgb(187,187=
,187);border-style:solid;border-width:1px"><code><div><span style=3D"color:=
#008">auto</span><span style=3D"color:#000"> arr </span><span style=3D"colo=
r:#660">:</span><span style=3D"color:#000"> </span><span style=3D"color:#66=
0">[</span><span style=3D"color:#000">n_1</span><span style=3D"color:#660">=
][</span><span style=3D"color:#000">n_2</span><span style=3D"color:#660">]-=
></span><span style=3D"color:#000">result_type</span><span style=3D"colo=
r:#660">;</span><span style=3D"color:#000"><br></span></div></code></div>?<=
br> <br></div></div></blockquote><div><br></div><div>No, why complicate lik=
e that?</div><div><br></div><div>What about:</div><div><div style=3D"backgr=
ound-color: rgb(250, 250, 250); border-color: rgb(187, 187, 187); border-st=
yle: solid; border-width: 1px; overflow-wrap: break-word;" class=3D"prettyp=
rint"><code class=3D"prettyprint"><div class=3D"subprettyprint"><span style=
=3D"color: #008;" class=3D"styled-by-prettify">auto</span><span style=3D"co=
lor: #000;" class=3D"styled-by-prettify"> arr</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: #008;" class=3D"sty=
led-by-prettify">int</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 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><br></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/519c2f35-c6b3-461f-89be-87ccd00f8be5%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/519c2f35-c6b3-461f-89be-87ccd00f8be5=
%40isocpp.org</a>.<br />
------=_Part_1269_1727749694.1534107967687--
------=_Part_1268_677895816.1534107967686--
.
Author: cppljevans@gmail.com
Date: Sun, 12 Aug 2018 14:55:55 -0700 (PDT)
Raw View
------=_Part_1266_1382176202.1534110955714
Content-Type: multipart/alternative;
boundary="----=_Part_1267_1934702710.1534110955714"
------=_Part_1267_1934702710.1534110955714
Content-Type: text/plain; charset="UTF-8"
On Sunday, August 12, 2018 at 4:06:07 PM UTC-5, Dimitrij Mijoski wrote:
>
> On Sunday, August 12, 2018 at 10:53:22 PM UTC+2, cpplj...@gmail.com wrote:
>>
>>
>> How would arrays be declared? Maybe:
>>
>> auto arr : [n_1][n_2]->result_type;
>> ?
>>
>>
> No, why complicate like that?
>
> What about:
> auto arr: int[3];
>
>
>
Well, I was only thinking of your desire for types to be "on the right".,
but I guess
you just meant that for functions? OTOH, an array is like a function
in that, when give a sequence of arguments, returns a result, and it would
be more uniform notation.
--
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/ef63d6a4-8296-45d9-9f67-96a440af2d45%40isocpp.org.
------=_Part_1267_1934702710.1534110955714
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr"><br><br>On Sunday, August 12, 2018 at 4:06:07 PM UTC-5, Di=
mitrij Mijoski wrote:<blockquote class=3D"gmail_quote" style=3D"margin: 0;m=
argin-left: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;"><div dir=
=3D"ltr">On Sunday, August 12, 2018 at 10:53:22 PM UTC+2, <a>cpplj...@gmail=
..com</a> wrote:<blockquote class=3D"gmail_quote" style=3D"margin:0;margin-l=
eft:0.8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir=3D"ltr"><br=
><div>How would arrays be declared? Maybe:<br></div><div><br></div><div><di=
v style=3D"background-color:rgb(250,250,250);border-color:rgb(187,187,187);=
border-style:solid;border-width:1px"><code><div><span style=3D"color:#008">=
auto</span><span style=3D"color:#000"> arr </span><span style=3D"color:#660=
">:</span><span style=3D"color:#000"> </span><span style=3D"color:#660">[</=
span><span style=3D"color:#000">n_1</span><span style=3D"color:#660">][</sp=
an><span style=3D"color:#000">n_2</span><span style=3D"color:#660">]-></=
span><span style=3D"color:#000">result_type</span><span style=3D"color:#660=
">;</span><span style=3D"color:#000"><br></span></div></code></div>?<br> <b=
r></div></div></blockquote><div><br></div><div>No, why complicate like that=
?</div><div><br></div><div>What about:</div><div><div style=3D"background-c=
olor:rgb(250,250,250);border-color:rgb(187,187,187);border-style:solid;bord=
er-width:1px"><code><div><span style=3D"color:#008">auto</span><span style=
=3D"color:#000"> arr</span><span style=3D"color:#660">:</span><span style=
=3D"color:#000"> </span><span style=3D"color:#008">int</span><span style=3D=
"color:#660">[</span><span style=3D"color:#066">3</span><span style=3D"colo=
r:#660">];</span><span style=3D"color:#000"><br></span></div></code></div><=
br><br></div></div></blockquote><div><br></div><div>Well, I was only thinki=
ng of your desire for types to be "on the right"., but I guess</d=
iv><div>you just meant that for functions?=C2=A0 OTOH, an array is like a f=
unction</div><div>in that, when give a sequence of arguments, returns a res=
ult, and it would</div><div>be more uniform notation.=C2=A0 <br></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/ef63d6a4-8296-45d9-9f67-96a440af2d45%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/ef63d6a4-8296-45d9-9f67-96a440af2d45=
%40isocpp.org</a>.<br />
------=_Part_1267_1934702710.1534110955714--
------=_Part_1266_1382176202.1534110955714--
.