Topic: Non-const but only user readable member objects
Author: =?UTF-8?Q?Aar=C3=B3n_Bueno_Villares?= <abv150ci@gmail.com>
Date: Thu, 30 Apr 2015 12:44:49 -0700 (PDT)
Raw View
------=_Part_240_1232149504.1430423089443
Content-Type: multipart/alternative;
boundary="----=_Part_241_551905707.1430423089443"
------=_Part_241_551905707.1430423089443
Content-Type: text/plain; charset=UTF-8
It's very common to have a member value which isn't const, but the user
cannot control its value. For example, boolean variables which informs
about the state of an object (camera position, readonly state, different
error situations...)
In such cases, you have to defined a `const` member function which returns
its value, without its set counterpart.
It would be good to have some kind of object member modifier which allows
the user to read a subobject without being capable to modify it, but
without the need of writing its get function, like:
struct A
{
readable bool failure = false;
void foo() { if (something) failure = true; }
}:
int main()
{
A a;
a.foo();
if (a.failure)
something();
a.failure = false; // Compilation error.
}
--
---
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.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposals/.
------=_Part_241_551905707.1430423089443
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr">It's very common to have a member value which isn't const,=
but the user cannot control its value. For example, boolean variables whic=
h informs about the state of an object (camera position, readonly state, di=
fferent error situations...)<br><br>In such cases, you have to defined a `c=
onst` member function which returns its value, without its set counterpart.=
<br><br>It would be good to have some kind of object member modifier which =
allows the user to read a subobject without being capable to modify it, but=
without the need of writing its get function, like:<br><br><div class=3D"p=
rettyprint" style=3D"background-color: rgb(250, 250, 250); border-color: rg=
b(187, 187, 187); border-style: solid; border-width: 1px; word-wrap: break-=
word;"><code class=3D"prettyprint"><div class=3D"subprettyprint"><span styl=
e=3D"color: #008;" class=3D"styled-by-prettify">struct</span><span style=3D=
"color: #000;" class=3D"styled-by-prettify"> A<br></span><span style=3D"col=
or: #660;" class=3D"styled-by-prettify">{</span><span style=3D"color: #000;=
" class=3D"styled-by-prettify"><br> readable </span><span style=3D"co=
lor: #008;" class=3D"styled-by-prettify">bool</span><span style=3D"color: #=
000;" class=3D"styled-by-prettify"> failure </span><span style=3D"color: #6=
60;" class=3D"styled-by-prettify">=3D</span><span style=3D"color: #000;" cl=
ass=3D"styled-by-prettify"> </span><span style=3D"color: #008;" class=3D"st=
yled-by-prettify">false</span><span style=3D"color: #660;" class=3D"styled-=
by-prettify">;</span><span style=3D"color: #000;" class=3D"styled-by-pretti=
fy"><br><br> </span><span style=3D"color: #008;" class=3D"styled-by-p=
rettify">void</span><span style=3D"color: #000;" class=3D"styled-by-prettif=
y"> foo</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: #660;" class=3D"styled-by-prettify">{</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color=
: #008;" class=3D"styled-by-prettify">if</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-b=
y-prettify">something</span><span style=3D"color: #660;" class=3D"styled-by=
-prettify">)</span><span style=3D"color: #000;" class=3D"styled-by-prettify=
"> failure </span><span style=3D"color: #660;" class=3D"styled-by-prettify"=
>=3D</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </spa=
n><span style=3D"color: #008;" class=3D"styled-by-prettify">true</span><spa=
n 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"><br></span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">}:</span><span style=3D"color: #000;" class=3D"styl=
ed-by-prettify"><br><br></span><span style=3D"color: #008;" class=3D"styled=
-by-prettify">int</span><span style=3D"color: #000;" class=3D"styled-by-pre=
ttify"> main</span><span style=3D"color: #660;" class=3D"styled-by-prettify=
">()</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br></=
span><span style=3D"color: #660;" class=3D"styled-by-prettify">{</span><spa=
n style=3D"color: #000;" class=3D"styled-by-prettify"><br> A a<=
/span><span style=3D"color: #660;" class=3D"styled-by-prettify">;</span><sp=
an style=3D"color: #000;" class=3D"styled-by-prettify"><br><br>  =
;a</span><span style=3D"color: #660;" class=3D"styled-by-prettify">.</span>=
<span style=3D"color: #000;" class=3D"styled-by-prettify">foo</span><span s=
tyle=3D"color: #660;" class=3D"styled-by-prettify">();</span><span style=3D=
"color: #000;" class=3D"styled-by-prettify"><br><br> </span><sp=
an style=3D"color: #008;" class=3D"styled-by-prettify">if</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">a</span><span style=3D"color: #660;" class=3D"=
styled-by-prettify">.</span><span style=3D"color: #000;" class=3D"styled-by=
-prettify">failure</span><span style=3D"color: #660;" class=3D"styled-by-pr=
ettify">)</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><=
br> something</span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">();</span><span style=3D"color: #000;" class=3D"sty=
led-by-prettify"><br><br> a</span><span style=3D"color: #660;" =
class=3D"styled-by-prettify">.</span><span style=3D"color: #000;" class=3D"=
styled-by-prettify">failure </span><span style=3D"color: #660;" class=3D"st=
yled-by-prettify">=3D</span><span style=3D"color: #000;" class=3D"styled-by=
-prettify"> </span><span style=3D"color: #008;" class=3D"styled-by-prettify=
">false</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: #800;" class=3D"styled-by-prettify">// Compilation error.=
</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br></span=
><span style=3D"color: #660;" class=3D"styled-by-prettify">}</span><span st=
yle=3D"color: #000;" class=3D"styled-by-prettify"><br><br></span></div></co=
de></div><br><br><br></div>
<p></p>
-- <br />
<br />
--- <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 />
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/">http://groups.google.com/a/isocpp.org/group/std-proposals/<=
/a>.<br />
------=_Part_241_551905707.1430423089443--
------=_Part_240_1232149504.1430423089443--
.
Author: masse.nicolas@gmail.com
Date: Thu, 30 Apr 2015 13:15:18 -0700 (PDT)
Raw View
------=_Part_148_1636109720.1430424918589
Content-Type: multipart/alternative;
boundary="----=_Part_149_1715447852.1430424918589"
------=_Part_149_1715447852.1430424918589
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
Hi,
I think the solution is to use make the failure member private and use a=20
public method to know wheter a faillure happened. I don't believe something=
=20
no need to be added into the language for that.
class A
{
bool failure =3D false;
public:
void foo() { if (something) failure =3D true; }
bool fails() const { return failure; }
}:
int main()
{
A a;
a.foo();
if (a.fails())
something();
a.failure =3D false; // Compilation error.
}
Le jeudi 30 avril 2015 21:44:49 UTC+2, Aar=C3=B3n Bueno Villares a =C3=A9cr=
it :
>
> It's very common to have a member value which isn't const, but the user=
=20
> cannot control its value. For example, boolean variables which informs=20
> about the state of an object (camera position, readonly state, different=
=20
> error situations...)
>
> In such cases, you have to defined a `const` member function which return=
s=20
> its value, without its set counterpart.
>
> It would be good to have some kind of object member modifier which allows=
=20
> the user to read a subobject without being capable to modify it, but=20
> without the need of writing its get function, like:
>
> struct A
> {
> readable bool failure =3D false;
>
> void foo() { if (something) failure =3D true; }
> }:
>
> int main()
> {
> A a;
>
> a.foo();
>
> if (a.failure)
> something();
>
> a.failure =3D false; // Compilation error.
> }
>
>
>
>
>
--=20
---=20
You received this message because you are subscribed to the Google Groups "=
ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposa=
ls/.
------=_Part_149_1715447852.1430424918589
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr">Hi,<br>I think the solution is to use make the failure mem=
ber private and use a public method to know wheter a faillure happened. I d=
on't believe something no need to be added into the language for that.<br><=
br><div class=3D"prettyprint" style=3D"background-color: rgb(250, 250, 250)=
; border-color: rgb(187, 187, 187); border-style: solid; border-width: 1px;=
word-wrap: break-word;"><code class=3D"prettyprint"><div class=3D"subprett=
yprint"><span style=3D"color: #008;" class=3D"styled-by-prettify">class</sp=
an><span style=3D"color: #000;" class=3D"styled-by-prettify"> A<br></span><=
span style=3D"color: #660;" class=3D"styled-by-prettify">{</span><span styl=
e=3D"color: #000;" class=3D"styled-by-prettify"><br> </span><span sty=
le=3D"color: #008;" class=3D"styled-by-prettify">bool</span><span style=3D"=
color: #000;" class=3D"styled-by-prettify"> failure </span><span style=3D"c=
olor: #660;" class=3D"styled-by-prettify">=3D</span><span style=3D"color: #=
000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #008;" cla=
ss=3D"styled-by-prettify">false</span><span style=3D"color: #660;" class=3D=
"styled-by-prettify">;</span><span style=3D"color: #000;" class=3D"styled-b=
y-prettify"><br></span><span style=3D"color: #008;" class=3D"styled-by-pret=
tify">public</span><span style=3D"color: #660;" class=3D"styled-by-prettify=
">:</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br>&nb=
sp; </span><span style=3D"color: #008;" class=3D"styled-by-prettify">void</=
span><span style=3D"color: #000;" class=3D"styled-by-prettify"> foo</span><=
span style=3D"color: #660;" class=3D"styled-by-prettify">()</span><span sty=
le=3D"color: #000;" class=3D"styled-by-prettify"> </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: #008;" class=
=3D"styled-by-prettify">if</span><span style=3D"color: #000;" class=3D"styl=
ed-by-prettify"> </span><span style=3D"color: #660;" class=3D"styled-by-pre=
ttify">(</span><span style=3D"color: #000;" class=3D"styled-by-prettify">so=
mething</span><span style=3D"color: #660;" class=3D"styled-by-prettify">)</=
span><span style=3D"color: #000;" class=3D"styled-by-prettify"> failure </s=
pan><span style=3D"color: #660;" class=3D"styled-by-prettify">=3D</span><sp=
an style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=
=3D"color: #008;" class=3D"styled-by-prettify">true</span><span style=3D"co=
lor: #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"style=
d-by-prettify"><br> </span><span style=3D"color: #008;" class=3D"styl=
ed-by-prettify">bool</span><span style=3D"color: #000;" class=3D"styled-by-=
prettify"> fails</span><span style=3D"color: #660;" class=3D"styled-by-pret=
tify">()</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> <=
/span><span style=3D"color: #008;" class=3D"styled-by-prettify">const</span=
><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span st=
yle=3D"color: #660;" class=3D"styled-by-prettify">{</span><span style=3D"co=
lor: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #008=
;" class=3D"styled-by-prettify">return</span><span style=3D"color: #000;" c=
lass=3D"styled-by-prettify"> failure</span><span style=3D"color: #660;" cla=
ss=3D"styled-by-prettify">;</span><span style=3D"color: #000;" class=3D"sty=
led-by-prettify"> </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><span style=3D"color: #660;" class=3D"styled-by-prettify">}:</spa=
n><span style=3D"color: #000;" class=3D"styled-by-prettify"><br><br></span>=
<span style=3D"color: #008;" class=3D"styled-by-prettify">int</span><span s=
tyle=3D"color: #000;" class=3D"styled-by-prettify"> main</span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">()</span><span style=3D"colo=
r: #000;" class=3D"styled-by-prettify"><br></span><span style=3D"color: #66=
0;" class=3D"styled-by-prettify">{</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"><br> A a</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><br> a</span><span style=3D"color:=
#660;" class=3D"styled-by-prettify">.</span><span style=3D"color: #000;" c=
lass=3D"styled-by-prettify">foo</span><span style=3D"color: #660;" class=3D=
"styled-by-prettify">();</span><span style=3D"color: #000;" class=3D"styled=
-by-prettify"><br><br> </span><span style=3D"color: #008;" clas=
s=3D"styled-by-prettify">if</span><span style=3D"color: #000;" class=3D"sty=
led-by-prettify"> </span><span style=3D"color: #660;" class=3D"styled-by-pr=
ettify">(</span><span style=3D"color: #000;" class=3D"styled-by-prettify">a=
</span><span style=3D"color: #660;" class=3D"styled-by-prettify">.</span><s=
pan style=3D"color: #000;" class=3D"styled-by-prettify">fails</span><span s=
tyle=3D"color: #660;" class=3D"styled-by-prettify">())</span><span style=3D=
"color: #000;" class=3D"styled-by-prettify"><br> someth=
ing</span><span style=3D"color: #660;" class=3D"styled-by-prettify">();</sp=
an><span style=3D"color: #000;" class=3D"styled-by-prettify"><br><br> =
a</span><span style=3D"color: #660;" class=3D"styled-by-prettify">.<=
/span><span style=3D"color: #000;" class=3D"styled-by-prettify">failure </s=
pan><span style=3D"color: #660;" class=3D"styled-by-prettify">=3D</span><sp=
an style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=
=3D"color: #008;" class=3D"styled-by-prettify">false</span><span style=3D"c=
olor: #660;" class=3D"styled-by-prettify">;</span><span style=3D"color: #00=
0;" class=3D"styled-by-prettify"> </span><span style=3D"color: #800;" class=
=3D"styled-by-prettify">// Compilation error.</span><span style=3D"color: #=
000;" class=3D"styled-by-prettify"><br></span><span style=3D"color: #660;" =
class=3D"styled-by-prettify">}</span></div></code></div><br><br><br>Le jeud=
i 30 avril 2015 21:44:49 UTC+2, Aar=C3=B3n Bueno Villares a =C3=A9crit =
;:<blockquote class=3D"gmail_quote" style=3D"margin: 0;margin-left: 0.8ex;b=
order-left: 1px #ccc solid;padding-left: 1ex;"><div dir=3D"ltr">It's very c=
ommon to have a member value which isn't const, but the user cannot control=
its value. For example, boolean variables which informs about the state of=
an object (camera position, readonly state, different error situations...)=
<br><br>In such cases, you have to defined a `const` member function which =
returns its value, without its set counterpart.<br><br>It would be good to =
have some kind of object member modifier which allows the user to read a su=
bobject without being capable to modify it, but without the need of writing=
its get function, like:<br><br><div style=3D"background-color:rgb(250,250,=
250);border-color:rgb(187,187,187);border-style:solid;border-width:1px;word=
-wrap:break-word"><code><div><span style=3D"color:#008">struct</span><span =
style=3D"color:#000"> A<br></span><span style=3D"color:#660">{</span><span =
style=3D"color:#000"><br> readable </span><span style=3D"color:#008">=
bool</span><span style=3D"color:#000"> failure </span><span style=3D"color:=
#660">=3D</span><span style=3D"color:#000"> </span><span style=3D"color:#00=
8">false</span><span style=3D"color:#660">;</span><span style=3D"color:#000=
"><br><br> </span><span style=3D"color:#008">void</span><span style=
=3D"color:#000"> foo</span><span style=3D"color:#660">()</span><span style=
=3D"color:#000"> </span><span style=3D"color:#660">{</span><span style=3D"c=
olor:#000"> </span><span style=3D"color:#008">if</span><span style=3D"color=
:#000"> </span><span style=3D"color:#660">(</span><span style=3D"color:#000=
">something</span><span style=3D"color:#660">)</span><span style=3D"color:#=
000"> failure </span><span style=3D"color:#660">=3D</span><span style=3D"co=
lor:#000"> </span><span style=3D"color:#008">true</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"><br></span><span style=3D"color:#660"=
>}:</span><span style=3D"color:#000"><br><br></span><span style=3D"color:#0=
08">int</span><span style=3D"color:#000"> main</span><span style=3D"color:#=
660">()</span><span style=3D"color:#000"><br></span><span style=3D"color:#6=
60">{</span><span style=3D"color:#000"><br> A a</span><span sty=
le=3D"color:#660">;</span><span style=3D"color:#000"><br><br> a=
</span><span style=3D"color:#660">.</span><span style=3D"color:#000">foo</s=
pan><span style=3D"color:#660">();</span><span style=3D"color:#000"><br><br=
> </span><span style=3D"color:#008">if</span><span style=3D"col=
or:#000"> </span><span style=3D"color:#660">(</span><span style=3D"color:#0=
00">a</span><span style=3D"color:#660">.</span><span style=3D"color:#000">f=
ailure</span><span style=3D"color:#660">)</span><span style=3D"color:#000">=
<br> something</span><span style=3D"color:#660">();</sp=
an><span style=3D"color:#000"><br><br> a</span><span style=3D"c=
olor:#660">.</span><span style=3D"color:#000">failure </span><span style=3D=
"color:#660">=3D</span><span style=3D"color:#000"> </span><span style=3D"co=
lor:#008">false</span><span style=3D"color:#660">;</span><span style=3D"col=
or:#000"> </span><span style=3D"color:#800">// Compilation error.</span><sp=
an style=3D"color:#000"><br></span><span style=3D"color:#660">}</span><span=
style=3D"color:#000"><br><br></span></div></code></div><br><br><br></div><=
/blockquote></div>
<p></p>
-- <br />
<br />
--- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals" group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<br />
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/">http://groups.google.com/a/isocpp.org/group/std-proposals/<=
/a>.<br />
------=_Part_149_1715447852.1430424918589--
------=_Part_148_1636109720.1430424918589--
.
Author: =?UTF-8?Q?Aar=C3=B3n_Bueno_Villares?= <abv150ci@gmail.com>
Date: Thu, 30 Apr 2015 13:58:05 -0700 (PDT)
Raw View
------=_Part_186_926228845.1430427485803
Content-Type: multipart/alternative;
boundary="----=_Part_187_19240812.1430427485803"
------=_Part_187_19240812.1430427485803
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
I think save writting is a good reason, like auto does.
El jueves, 30 de abril de 2015, 21:44:49 (UTC+2), Aar=C3=B3n Bueno Villares=
=20
escribi=C3=B3:
>
> It's very common to have a member value which isn't const, but the user=
=20
> cannot control its value. For example, boolean variables which informs=20
> about the state of an object (camera position, readonly state, different=
=20
> error situations...)
>
> In such cases, you have to defined a `const` member function which return=
s=20
> its value, without its set counterpart.
>
> It would be good to have some kind of object member modifier which allows=
=20
> the user to read a subobject without being capable to modify it, but=20
> without the need of writing its get function, like:
>
> struct A
> {
> readable bool failure =3D false;
>
> void foo() { if (something) failure =3D true; }
> }:
>
> int main()
> {
> A a;
>
> a.foo();
>
> if (a.failure)
> something();
>
> a.failure =3D false; // Compilation error.
> }
>
>
>
>
>
--=20
---=20
You received this message because you are subscribed to the Google Groups "=
ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposa=
ls/.
------=_Part_187_19240812.1430427485803
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr">I think save writting is a good reason, like auto does.<br=
><br>El jueves, 30 de abril de 2015, 21:44:49 (UTC+2), Aar=C3=B3n Bueno Vil=
lares escribi=C3=B3:<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">It's very common to have a member value which isn't const, but the=
user cannot control its value. For example, boolean variables which inform=
s about the state of an object (camera position, readonly state, different =
error situations...)<br><br>In such cases, you have to defined a `const` me=
mber function which returns its value, without its set counterpart.<br><br>=
It would be good to have some kind of object member modifier which allows t=
he user to read a subobject without being capable to modify it, but without=
the need of writing its get function, like:<br><br><div style=3D"backgroun=
d-color:rgb(250,250,250);border-color:rgb(187,187,187);border-style:solid;b=
order-width:1px;word-wrap:break-word"><code><div><span style=3D"color:#008"=
>struct</span><span style=3D"color:#000"> A<br></span><span style=3D"color:=
#660">{</span><span style=3D"color:#000"><br> readable </span><span s=
tyle=3D"color:#008">bool</span><span style=3D"color:#000"> failure </span><=
span style=3D"color:#660">=3D</span><span style=3D"color:#000"> </span><spa=
n style=3D"color:#008">false</span><span style=3D"color:#660">;</span><span=
style=3D"color:#000"><br><br> </span><span style=3D"color:#008">void=
</span><span style=3D"color:#000"> foo</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 style=3D"color:#008">if</span><sp=
an style=3D"color:#000"> </span><span style=3D"color:#660">(</span><span st=
yle=3D"color:#000">something</span><span style=3D"color:#660">)</span><span=
style=3D"color:#000"> failure </span><span style=3D"color:#660">=3D</span>=
<span style=3D"color:#000"> </span><span style=3D"color:#008">true</span><s=
pan style=3D"color:#660">;</span><span style=3D"color:#000"> </span><span s=
tyle=3D"color:#660">}</span><span style=3D"color:#000"><br></span><span sty=
le=3D"color:#660">}:</span><span style=3D"color:#000"><br><br></span><span =
style=3D"color:#008">int</span><span style=3D"color:#000"> main</span><span=
style=3D"color:#660">()</span><span style=3D"color:#000"><br></span><span =
style=3D"color:#660">{</span><span style=3D"color:#000"><br> A =
a</span><span style=3D"color:#660">;</span><span style=3D"color:#000"><br><=
br> a</span><span style=3D"color:#660">.</span><span style=3D"c=
olor:#000">foo</span><span style=3D"color:#660">();</span><span style=3D"co=
lor:#000"><br><br> </span><span style=3D"color:#008">if</span><=
span style=3D"color:#000"> </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">failure</span><span style=3D"color:#660">)</span><span styl=
e=3D"color:#000"><br> something</span><span style=3D"co=
lor:#660">();</span><span style=3D"color:#000"><br><br> a</span=
><span style=3D"color:#660">.</span><span style=3D"color:#000">failure </sp=
an><span style=3D"color:#660">=3D</span><span style=3D"color:#000"> </span>=
<span style=3D"color:#008">false</span><span style=3D"color:#660">;</span><=
span style=3D"color:#000"> </span><span style=3D"color:#800">// Compilation=
error.</span><span style=3D"color:#000"><br></span><span style=3D"color:#6=
60">}</span><span style=3D"color:#000"><br><br></span></div></code></div><b=
r><br><br></div></blockquote></div>
<p></p>
-- <br />
<br />
--- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals" group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<br />
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/">http://groups.google.com/a/isocpp.org/group/std-proposals/<=
/a>.<br />
------=_Part_187_19240812.1430427485803--
------=_Part_186_926228845.1430427485803--
.
Author: masse.nicolas@gmail.com
Date: Thu, 30 Apr 2015 14:34:27 -0700 (PDT)
Raw View
------=_Part_245_244457902.1430429667413
Content-Type: multipart/alternative;
boundary="----=_Part_246_467742203.1430429667413"
------=_Part_246_467742203.1430429667413
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
I do not think that just saving typing is a good enough reason.=20
auto does more than just save you typing.=20
It also makes the compiler compute the type for you. This can be very=20
interesting if for example you change the type from a list into a vector=20
for example (because you don't have to change the std::list<x>::iterator=20
into a std::vector<x>::iterator everywhere in your program).
Also, it ensure that the compiler will compute the exact type of your=20
variable, avoiding implicit conversion.=20
If you want more about this, have a look at=20
http://herbsutter.com/2013/08/12/gotw-94-solution-aaa-style-almost-always-a=
uto/.=20
It gives you enough examples of why you should use auto and what it=20
provides to the programmer..=20
From the article :
> Remember that preferring *auto* variables is motivated primarily by=20
> correctness, performance, maintainability, and robustness=E2=80=94and onl=
y lastly=20
> about typing convenience.
So I do believe that your proposal should have more than just saving you=20
typing for being relevant.
Just my 2 cents :).=20
Le jeudi 30 avril 2015 22:58:05 UTC+2, Aar=C3=B3n Bueno Villares a =C3=A9cr=
it :
>
> I think save writting is a good reason, like auto does.
>
> El jueves, 30 de abril de 2015, 21:44:49 (UTC+2), Aar=C3=B3n Bueno Villar=
es=20
> escribi=C3=B3:
>>
>> It's very common to have a member value which isn't const, but the user=
=20
>> cannot control its value. For example, boolean variables which informs=
=20
>> about the state of an object (camera position, readonly state, different=
=20
>> error situations...)
>>
>> In such cases, you have to defined a `const` member function which=20
>> returns its value, without its set counterpart.
>>
>> It would be good to have some kind of object member modifier which allow=
s=20
>> the user to read a subobject without being capable to modify it, but=20
>> without the need of writing its get function, like:
>>
>> struct A
>> {
>> readable bool failure =3D false;
>>
>> void foo() { if (something) failure =3D true; }
>> }:
>>
>> int main()
>> {
>> A a;
>>
>> a.foo();
>>
>> if (a.failure)
>> something();
>>
>> a.failure =3D false; // Compilation error.
>> }
>>
>>
>>
>>
>>
--=20
---=20
You received this message because you are subscribed to the Google Groups "=
ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposa=
ls/.
------=_Part_246_467742203.1430429667413
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr">I do not think that just saving typing is a good enough re=
ason. <br>auto does more than just save you typing. <br>It also makes the c=
ompiler compute the type for you. This can be very interesting if for examp=
le you change the type from a list into a vector for example (because you d=
on't have to change the std::list<x>::iterator into a std::vector<=
x>::iterator everywhere in your program).<br>Also, it ensure that the co=
mpiler will compute the exact type of your variable, avoiding implicit conv=
ersion. <br>If you want more about this, have a look at http://herbsutter.c=
om/2013/08/12/gotw-94-solution-aaa-style-almost-always-auto/. It gives you =
enough examples of why you should use auto and what it provides to the prog=
rammer.. <br><br>From the article :<br><blockquote style=3D"margin: 0px 0px=
0px 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;" =
class=3D"gmail_quote">Remember that preferring <strong>auto</strong> variab=
les is motivated=20
primarily by correctness, performance, maintainability, and=20
robustness=E2=80=94and only lastly about typing convenience.</blockquote><d=
iv><br>So I do believe that your proposal should have more than just saving=
you typing for being relevant.<br><br>Just my 2 cents :). <br></div><br>Le=
jeudi 30 avril 2015 22:58:05 UTC+2, Aar=C3=B3n Bueno Villares a =C3=A9crit=
:<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">I thin=
k save writting is a good reason, like auto does.<br><br>El jueves, 30 de a=
bril de 2015, 21:44:49 (UTC+2), Aar=C3=B3n Bueno Villares escribi=C3=B3:<b=
lockquote class=3D"gmail_quote" style=3D"margin:0;margin-left:0.8ex;border-=
left:1px #ccc solid;padding-left:1ex"><div dir=3D"ltr">It's very common to =
have a member value which isn't const, but the user cannot control its valu=
e. For example, boolean variables which informs about the state of an objec=
t (camera position, readonly state, different error situations...)<br><br>I=
n such cases, you have to defined a `const` member function which returns i=
ts value, without its set counterpart.<br><br>It would be good to have some=
kind of object member modifier which allows the user to read a subobject w=
ithout being capable to modify it, but without the need of writing its get =
function, like:<br><br><div style=3D"background-color:rgb(250,250,250);bord=
er-color:rgb(187,187,187);border-style:solid;border-width:1px;word-wrap:bre=
ak-word"><code><div><span style=3D"color:#008">struct</span><span style=3D"=
color:#000"> A<br></span><span style=3D"color:#660">{</span><span style=3D"=
color:#000"><br> readable </span><span style=3D"color:#008">bool</spa=
n><span style=3D"color:#000"> failure </span><span style=3D"color:#660">=3D=
</span><span style=3D"color:#000"> </span><span style=3D"color:#008">false<=
/span><span style=3D"color:#660">;</span><span style=3D"color:#000"><br><br=
> </span><span style=3D"color:#008">void</span><span style=3D"color:#=
000"> foo</span><span style=3D"color:#660">()</span><span style=3D"color:#0=
00"> </span><span style=3D"color:#660">{</span><span style=3D"color:#000"> =
</span><span style=3D"color:#008">if</span><span style=3D"color:#000"> </sp=
an><span style=3D"color:#660">(</span><span style=3D"color:#000">something<=
/span><span style=3D"color:#660">)</span><span style=3D"color:#000"> failur=
e </span><span style=3D"color:#660">=3D</span><span style=3D"color:#000"> <=
/span><span style=3D"color:#008">true</span><span style=3D"color:#660">;</s=
pan><span style=3D"color:#000"> </span><span style=3D"color:#660">}</span><=
span style=3D"color:#000"><br></span><span style=3D"color:#660">}:</span><s=
pan style=3D"color:#000"><br><br></span><span style=3D"color:#008">int</spa=
n><span style=3D"color:#000"> main</span><span style=3D"color:#660">()</spa=
n><span style=3D"color:#000"><br></span><span style=3D"color:#660">{</span>=
<span style=3D"color:#000"><br> A a</span><span style=3D"color:=
#660">;</span><span style=3D"color:#000"><br><br> a</span><span=
style=3D"color:#660">.</span><span style=3D"color:#000">foo</span><span st=
yle=3D"color:#660">();</span><span style=3D"color:#000"><br><br> &nbs=
p;</span><span style=3D"color:#008">if</span><span style=3D"color:#000"> </=
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">failure</span=
><span style=3D"color:#660">)</span><span style=3D"color:#000"><br> &=
nbsp; something</span><span style=3D"color:#660">();</span><span sty=
le=3D"color:#000"><br><br> a</span><span style=3D"color:#660">.=
</span><span style=3D"color:#000">failure </span><span style=3D"color:#660"=
>=3D</span><span style=3D"color:#000"> </span><span style=3D"color:#008">fa=
lse</span><span style=3D"color:#660">;</span><span style=3D"color:#000"> </=
span><span style=3D"color:#800">// Compilation error.</span><span style=3D"=
color:#000"><br></span><span style=3D"color:#660">}</span><span style=3D"co=
lor:#000"><br><br></span></div></code></div><br><br><br></div></blockquote>=
</div></blockquote></div>
<p></p>
-- <br />
<br />
--- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals" group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<br />
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/">http://groups.google.com/a/isocpp.org/group/std-proposals/<=
/a>.<br />
------=_Part_246_467742203.1430429667413--
------=_Part_245_244457902.1430429667413--
.