Topic: Explicitly specify what class members some method
Author: vityatheboss@gmail.com
Date: Wed, 13 May 2015 04:24:30 -0700 (PDT)
Raw View
------=_Part_186_456715127.1431516270884
Content-Type: multipart/alternative;
boundary="----=_Part_187_904585111.1431516270884"
------=_Part_187_904585111.1431516270884
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
Or more c++-like syntax like:
class A {
public:
void f() modify(a_) {
a_ =3D b_ + c_;
}
private:
int a_;
int b_;
int c_;
};
=D1=81=D1=80=D0=B5=D0=B4=D0=B0, 13 =D0=BC=D0=B0=D1=8F 2015 =D0=B3., 14:20:0=
9 UTC+3 =D0=BF=D0=BE=D0=BB=D1=8C=D0=B7=D0=BE=D0=B2=D0=B0=D1=82=D0=B5=D0=BB=
=D1=8C vityat...@gmail.com=20
=D0=BD=D0=B0=D0=BF=D0=B8=D1=81=D0=B0=D0=BB:
>
> It is good to know what class attributes can be changed in the non-const=
=20
> method:
>
> class A {
> public:
>
> @modify(a_)
> void f() {
> a_ =3D b_ + c_;
> }
> private:
> int a_;
> int b_;
> int c_;
> };
>
>
>
> In this case we can be sure that the method does not change any other=20
> attribute of the object. In this example it may not be much useful but in=
=20
> large methods it is very useful in my opinion.
>
--=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_904585111.1431516270884
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr">Or more c++-like syntax like:<br><br><code><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">class</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;" cl=
ass=3D"styled-by-prettify"><br></span><span style=3D"color: #008;" class=3D=
"styled-by-prettify">public</span><span style=3D"color: #660;" class=3D"sty=
led-by-prettify">:</span><span style=3D"color: #000;" class=3D"styled-by-pr=
ettify"><br><br></span><span style=3D"color: #008;" class=3D"styled-by-pret=
tify">void</span><span style=3D"color: #000;" class=3D"styled-by-prettify">=
f</span><span style=3D"color: #660;" class=3D"styled-by-prettify">()</span=
><span style=3D"color: #000;" class=3D"styled-by-prettify"> modify</span><s=
pan 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"colo=
r: #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-b=
y-prettify"><br> a_ </span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">=3D</span><span style=3D"color: #000;" class=3D"sty=
led-by-prettify"> b_ </span><span style=3D"color: #660;" class=3D"styled-by=
-prettify">+</span><span style=3D"color: #000;" class=3D"styled-by-prettify=
"> c_</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><sp=
an style=3D"color: #660;" class=3D"styled-by-prettify">}</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"><br></span><span style=3D"co=
lor: #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> </span><span style=3D"color:=
#008;" class=3D"styled-by-prettify">int</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"style=
d-by-prettify"><br> </span><span style=3D"color: #008;" class=
=3D"styled-by-prettify">int</span><span style=3D"color: #000;" class=3D"sty=
led-by-prettify"> b_</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-p=
rettify">int</span><span style=3D"color: #000;" class=3D"styled-by-prettify=
"> c_</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><sp=
an style=3D"color: #660;" class=3D"styled-by-prettify">};</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"><br><br></span></div></code>=
</div><span style=3D"color:#000"><br></span></code><br><br>=D1=81=D1=80=D0=
=B5=D0=B4=D0=B0, 13 =D0=BC=D0=B0=D1=8F 2015 =D0=B3., 14:20:09 UTC+3 =D0=BF=
=D0=BE=D0=BB=D1=8C=D0=B7=D0=BE=D0=B2=D0=B0=D1=82=D0=B5=D0=BB=D1=8C vityat..=
..@gmail.com =D0=BD=D0=B0=D0=BF=D0=B8=D1=81=D0=B0=D0=BB:<blockquote class=3D=
"gmail_quote" style=3D"margin: 0;margin-left: 0.8ex;border-left: 1px #ccc s=
olid;padding-left: 1ex;"><div dir=3D"ltr">It is good to know what class att=
ributes can be changed in the non-const method:<br><br><div style=3D"backgr=
ound-color:rgb(250,250,250);border-color:rgb(187,187,187);border-style:soli=
d;border-width:1px;word-wrap:break-word"><code><div><span style=3D"color:#0=
08">class</span><span style=3D"color:#000"> A </span><span style=3D"color:#=
660">{</span><span style=3D"color:#000"><br></span><span style=3D"color:#00=
8">public</span><span style=3D"color:#660">:</span><span style=3D"color:#00=
0"><br><br></span><span style=3D"color:#066">@modify</span><span style=3D"c=
olor:#660">(</span><span style=3D"color:#000">a_</span><span style=3D"color=
:#660">)</span><span style=3D"color:#000"><br></span><span style=3D"color:#=
008">void</span><span style=3D"color:#000"> f</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"><br> a_ </span><span style=
=3D"color:#660">=3D</span><span style=3D"color:#000"> b_ </span><span style=
=3D"color:#660">+</span><span style=3D"color:#000"> c_</span><span style=3D=
"color:#660">;</span><span style=3D"color:#000"><br></span><span style=3D"c=
olor:#660">}</span><span style=3D"color:#000"><br></span><span style=3D"col=
or:#008">private</span><span style=3D"color:#660">:</span><span style=3D"co=
lor:#000"><br> </span><span style=3D"color:#008">int</span><sp=
an style=3D"color:#000"> a_</span><span style=3D"color:#660">;</span><span =
style=3D"color:#000"><br> </span><span style=3D"color:#008">in=
t</span><span style=3D"color:#000"> b_</span><span style=3D"color:#660">;</=
span><span style=3D"color:#000"><br> </span><span style=3D"col=
or:#008">int</span><span style=3D"color:#000"> c_</span><span style=3D"colo=
r:#660">;</span><span 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>In this case we can be sure that the method does not change any ot=
her attribute of the object. In this example it may not be much useful but =
in large methods it is very useful in my opinion.<br></div></blockquote></d=
iv>
<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_904585111.1431516270884--
------=_Part_186_456715127.1431516270884--
.
Author: Houe <mboyko2000@gmail.com>
Date: Wed, 13 May 2015 05:54:09 -0700 (PDT)
Raw View
------=_Part_3365_1375929953.1431521649290
Content-Type: multipart/alternative;
boundary="----=_Part_3366_1150809175.1431521649290"
------=_Part_3366_1150809175.1431521649290
Content-Type: text/plain; charset=UTF-8
Or use mutable (see updated example)... However this is starting to look
like the failed throw() specifications - it was found that only knowing
if the functions throws or not is important hence noexcept. I'm guessing
its only important whether a function is const or not const. We already
have a way to specify mutability for members just not one a function by
function basis.
class A {
> public:
>
> void f() mutable(a_) {
> a_ = b_ + c_;
> }
> private:
> int a_;
> int b_;
> int c_;
> };
>
>
>
>
--
---
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_3366_1150809175.1431521649290
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr"><div>Or use mutable (see updated example)... However this =
is starting to look like the failed throw() specifications - it was found t=
hat only knowing if the functions throws or not is important henc=
e noexcept. I'm guessing its only important whether a function is const or =
not const. We already have a way to specify mutability for members just not=
one a function by function basis.<br></div><div><br><br></div><code><div><=
br></div><blockquote class=3D"gmail_quote" style=3D"margin: 0px 0px 0px 0.8=
ex; padding-left: 1ex; border-left-color: rgb(204, 204, 204); border-left-w=
idth: 1px; border-left-style: solid;"><div dir=3D"ltr"><div style=3D"border=
: 1px solid rgb(187, 187, 187); border-image: none; -ms-word-wrap: break-wo=
rd; background-color: rgb(250, 250, 250);"><code><div><span style=3D"color:=
rgb(0, 0, 136);">class</span><span style=3D"color: rgb(0, 0, 0);"> A </spa=
n><span style=3D"color: rgb(102, 102, 0);">{</span><span style=3D"color: rg=
b(0, 0, 0);"><br></span><span style=3D"color: rgb(0, 0, 136);">public</span=
><span style=3D"color: rgb(102, 102, 0);">:</span><span style=3D"color: rgb=
(0, 0, 0);"><br><br></span><span style=3D"color: rgb(0, 0, 136);">void</spa=
n><span style=3D"color: rgb(0, 0, 0);"> f</span><span style=3D"color: rgb(1=
02, 102, 0);">()</span><span style=3D"color: rgb(0, 0, 0);"> mutable</span>=
<span style=3D"color: rgb(102, 102, 0);">(</span><span style=3D"color: rgb(=
0, 0, 0);">a_</span><span style=3D"color: rgb(102, 102, 0);">)</span><span =
style=3D"color: rgb(0, 0, 0);"> </span><span style=3D"color: rgb(102, 102, =
0);">{</span><span style=3D"color: rgb(0, 0, 0);"><br> a_ </sp=
an><span style=3D"color: rgb(102, 102, 0);">=3D</span><span style=3D"color:=
rgb(0, 0, 0);"> b_ </span><span style=3D"color: rgb(102, 102, 0);">+</span=
><span style=3D"color: rgb(0, 0, 0);"> c_</span><span style=3D"color: rgb(1=
02, 102, 0);">;</span><span style=3D"color: rgb(0, 0, 0);"><br></span><span=
style=3D"color: rgb(102, 102, 0);">}</span><span style=3D"color: rgb(0, 0,=
0);"><br></span><span style=3D"color: rgb(0, 0, 136);">private</span><span=
style=3D"color: rgb(102, 102, 0);">:</span><span style=3D"color: rgb(0, 0,=
0);"><br> </span><span style=3D"color: rgb(0, 0, 136);">int</=
span><span style=3D"color: rgb(0, 0, 0);"> a_</span><span style=3D"color: r=
gb(102, 102, 0);">;</span><span style=3D"color: rgb(0, 0, 0);"><br> &=
nbsp; </span><span style=3D"color: rgb(0, 0, 136);">int</span><span style=
=3D"color: rgb(0, 0, 0);"> b_</span><span style=3D"color: rgb(102, 102, 0);=
">;</span><span style=3D"color: rgb(0, 0, 0);"><br> </span><sp=
an style=3D"color: rgb(0, 0, 136);">int</span><span style=3D"color: rgb(0, =
0, 0);"> c_</span><span style=3D"color: rgb(102, 102, 0);">;</span><span st=
yle=3D"color: rgb(0, 0, 0);"><br></span><span style=3D"color: rgb(102, 102,=
0);">};</span><span style=3D"color: rgb(0, 0, 0);"><br><br></span></div></=
code></div><span style=3D"color: rgb(0, 0, 0);"><br></span></div></blockquo=
te></code><blockquote class=3D"gmail_quote" style=3D"margin: 0px 0px 0px 0.=
8ex; padding-left: 1ex; border-left-color: rgb(204, 204, 204); border-left-=
width: 1px; border-left-style: solid;"><div dir=3D"ltr"><br></div></blockqu=
ote></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_3366_1150809175.1431521649290--
------=_Part_3365_1375929953.1431521649290--
.
Author: Andrey Semashev <andrey.semashev@gmail.com>
Date: Wed, 13 May 2015 16:04:24 +0300
Raw View
On Wed, May 13, 2015 at 2:20 PM, <vityatheboss@gmail.com> wrote:
> It is good to know what class attributes can be changed in the non-const
> method:
>
> class A {
> public:
>
> @modify(a_)
> void f() {
> a_ = b_ + c_;
> }
> private:
> int a_;
> int b_;
> int c_;
> };
>
>
>
> In this case we can be sure that the method does not change any other
> attribute of the object. In this example it may not be much useful but in
> large methods it is very useful in my opinion.
I think it is better to design the class and method properly. Maybe
extract a portion of functionality to a separate class/function with a
well defined interface.
--
---
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/.
.
Author: vityatheboss@gmail.com
Date: Wed, 13 May 2015 06:24:35 -0700 (PDT)
Raw View
------=_Part_526_225167745.1431523475058
Content-Type: multipart/alternative;
boundary="----=_Part_527_528104201.1431523475058"
------=_Part_527_528104201.1431523475058
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
`mutable` is okay but we already have `mutable` keyword for the class=20
attributes and using it in method declaration may cause some=20
misunderstanding. You are right about throw and noexcept but I think it has=
=20
some more use than throw(). Also, specifying method by 'const' or not means=
=20
that it can not change any attribute in the class. It is good for const=20
methods. But if we have some really wide method which was not marked const=
=20
then it means this method can do everything with the attributes. Consider=
=20
the following code:
class A {
public:
int calculateSum(int a, int b) {
currentTemperatureOnSun_ =3D 30;
b +=3D 500;
return lastSum_ =3D a + b;
}
private:
int lastSum_ =3D 0;
int currentTemperatureOnSun_ =3D 0;
};
This example demonstrates how it is easy for developer specially or not to=
=20
change the object attributes which are not needed to be changed. If the=20
method is large enough (which is not so rare case actually) it is hard to=
=20
detect which attributes and where were changed.
Of course we can say "everything is on developer's responsibility" but what=
=20
about other contributors? Why do c++11 have "override" keyword which is not=
=20
really necessary (but of course it helps) but it can't have one more=20
keyword which may actually help too?
=D1=81=D1=80=D0=B5=D0=B4=D0=B0, 13 =D0=BC=D0=B0=D1=8F 2015 =D0=B3., 15:54:0=
9 UTC+3 =D0=BF=D0=BE=D0=BB=D1=8C=D0=B7=D0=BE=D0=B2=D0=B0=D1=82=D0=B5=D0=BB=
=D1=8C Houe =D0=BD=D0=B0=D0=BF=D0=B8=D1=81=D0=B0=D0=BB:
>
> Or use mutable (see updated example)... However this is starting to look=
=20
> like the failed throw() specifications - it was found that only knowing=
=20
> if the functions throws or not is important hence noexcept. I'm guessing=
=20
> its only important whether a function is const or not const. We already=
=20
> have a way to specify mutability for members just not one a function by=
=20
> function basis.
>
>
>
> class A {
>> public:
>>
>> void f() mutable(a_) {
>> a_ =3D b_ + c_;
>> }
>> private:
>> int a_;
>> int b_;
>> int c_;
>> };
>>
>>
>>
>>
--=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_527_528104201.1431523475058
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr">`mutable` is okay but we already have `mutable` keyword fo=
r the class attributes and using it in method declaration may cause some mi=
sunderstanding. You are right about throw and noexcept but I think it has s=
ome more use than throw(). Also, specifying method by 'const' or not means =
that it can not change any attribute in the class. It is good for const met=
hods. But if we have some really wide method which was not marked const the=
n it means this method can do everything with the attributes. Consider the =
following code:<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"><d=
iv class=3D"subprettyprint"><span style=3D"color: #008;" class=3D"styled-by=
-prettify">class</span><span style=3D"color: #000;" class=3D"styled-by-pret=
tify"> A </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">public</span><sp=
an style=3D"color: #660;" class=3D"styled-by-prettify">:</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"><br> </span><sp=
an style=3D"color: #008;" class=3D"styled-by-prettify">int</span><span styl=
e=3D"color: #000;" class=3D"styled-by-prettify"> calculateSum</span><span s=
tyle=3D"color: #660;" class=3D"styled-by-prettify">(</span><span style=3D"c=
olor: #008;" class=3D"styled-by-prettify">int</span><span style=3D"color: #=
000;" class=3D"styled-by-prettify"> a</span><span style=3D"color: #660;" cl=
ass=3D"styled-by-prettify">,</span><span style=3D"color: #000;" class=3D"st=
yled-by-prettify"> </span><span style=3D"color: #008;" class=3D"styled-by-p=
rettify">int</span><span style=3D"color: #000;" class=3D"styled-by-prettify=
"> b</span><span style=3D"color: #660;" class=3D"styled-by-prettify">)</spa=
n><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span s=
tyle=3D"color: #660;" class=3D"styled-by-prettify">{</span><span style=3D"c=
olor: #000;" class=3D"styled-by-prettify"><br> c=
urrentTemperatureOnSun_ </span><span style=3D"color: #660;" class=3D"styled=
-by-prettify">=3D</span><span style=3D"color: #000;" class=3D"styled-by-pre=
ttify"> </span><span style=3D"color: #066;" class=3D"styled-by-prettify">30=
</span><span style=3D"color: #660;" class=3D"styled-by-prettify">;</span><s=
pan style=3D"color: #000;" class=3D"styled-by-prettify"><br> &=
nbsp; b </span><span style=3D"color: #660;" class=3D"styled-by-prett=
ify">+=3D</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> =
</span><span style=3D"color: #066;" class=3D"styled-by-prettify">500</span>=
<span style=3D"color: #660;" class=3D"styled-by-prettify">;</span><span sty=
le=3D"color: #000;" class=3D"styled-by-prettify"><br> &=
nbsp; </span><span style=3D"color: #008;" class=3D"styled-by-prettify">retu=
rn</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> lastSum=
_ </span><span style=3D"color: #660;" class=3D"styled-by-prettify">=3D</spa=
n><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"> b</span><span style=3D"color: =
#660;" class=3D"styled-by-prettify">;</span><span style=3D"color: #000;" cl=
ass=3D"styled-by-prettify"><br> </span><span style=3D"color: #=
660;" class=3D"styled-by-prettify">}</span><span style=3D"color: #000;" cla=
ss=3D"styled-by-prettify"><br><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-b=
y-prettify"><br> </span><span style=3D"color: #008;" class=3D"=
styled-by-prettify">int</span><span style=3D"color: #000;" class=3D"styled-=
by-prettify"> lastSum_ </span><span style=3D"color: #660;" class=3D"styled-=
by-prettify">=3D</span><span style=3D"color: #000;" class=3D"styled-by-pret=
tify"> </span><span style=3D"color: #066;" class=3D"styled-by-prettify">0</=
span><span style=3D"color: #660;" class=3D"styled-by-prettify">;</span><spa=
n style=3D"color: #000;" class=3D"styled-by-prettify"><br> </s=
pan><span style=3D"color: #008;" class=3D"styled-by-prettify">int</span><sp=
an style=3D"color: #000;" class=3D"styled-by-prettify"> currentTemperatureO=
nSun_ </span><span style=3D"color: #660;" class=3D"styled-by-prettify">=3D<=
/span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><sp=
an style=3D"color: #066;" class=3D"styled-by-prettify">0</span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">;</span><span style=3D"color=
: #000;" class=3D"styled-by-prettify"><br></span><span style=3D"color: #660=
;" class=3D"styled-by-prettify">};</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"><br></span></div></code></div><br>This example demo=
nstrates how it is easy for developer specially or not to change the object=
attributes which are not needed to be changed. If the method is large enou=
gh (which is not so rare case actually) it is hard to detect which attribut=
es and where were changed.<br>Of course we can say "everything is on develo=
per's responsibility" but what about other contributors? Why do c++11 have =
"override" keyword which is not really necessary (but of course it helps) b=
ut it can't have one more keyword which may actually help too?<br><br><br>=
=D1=81=D1=80=D0=B5=D0=B4=D0=B0, 13 =D0=BC=D0=B0=D1=8F 2015 =D0=B3., 15:54:0=
9 UTC+3 =D0=BF=D0=BE=D0=BB=D1=8C=D0=B7=D0=BE=D0=B2=D0=B0=D1=82=D0=B5=D0=BB=
=D1=8C Houe =D0=BD=D0=B0=D0=BF=D0=B8=D1=81=D0=B0=D0=BB:<blockquote class=3D=
"gmail_quote" style=3D"margin: 0;margin-left: 0.8ex;border-left: 1px #ccc s=
olid;padding-left: 1ex;"><div dir=3D"ltr"><div>Or use mutable (see updated =
example)... However this is starting to look like the failed throw() specif=
ications - it was found that only knowing if the functions throws=
or not is important hence noexcept. I'm guessing its only important whethe=
r a function is const or not const. We already have a way to specify mutabi=
lity for members just not one a function by function basis.<br></div><div><=
br><br></div><code><div><br></div><blockquote class=3D"gmail_quote" style=
=3D"margin:0px 0px 0px 0.8ex;padding-left:1ex;border-left-color:rgb(204,204=
,204);border-left-width:1px;border-left-style:solid"><div dir=3D"ltr"><div =
style=3D"border:1px solid rgb(187,187,187);background-color:rgb(250,250,250=
)"><code><div><span style=3D"color:rgb(0,0,136)">class</span><span style=3D=
"color:rgb(0,0,0)"> A </span><span style=3D"color:rgb(102,102,0)">{</span><=
span style=3D"color:rgb(0,0,0)"><br></span><span style=3D"color:rgb(0,0,136=
)">public</span><span style=3D"color:rgb(102,102,0)">:</span><span style=3D=
"color:rgb(0,0,0)"><br><br></span><span style=3D"color:rgb(0,0,136)">void</=
span><span style=3D"color:rgb(0,0,0)"> f</span><span style=3D"color:rgb(102=
,102,0)">()</span><span style=3D"color:rgb(0,0,0)"> mutable</span><span sty=
le=3D"color:rgb(102,102,0)">(</span><span style=3D"color:rgb(0,0,0)">a_</sp=
an><span style=3D"color:rgb(102,102,0)">)</span><span style=3D"color:rgb(0,=
0,0)"> </span><span style=3D"color:rgb(102,102,0)">{</span><span style=3D"c=
olor:rgb(0,0,0)"><br> a_ </span><span style=3D"color:rgb(102,1=
02,0)">=3D</span><span style=3D"color:rgb(0,0,0)"> b_ </span><span style=3D=
"color:rgb(102,102,0)">+</span><span style=3D"color:rgb(0,0,0)"> c_</span><=
span style=3D"color:rgb(102,102,0)">;</span><span style=3D"color:rgb(0,0,0)=
"><br></span><span style=3D"color:rgb(102,102,0)">}</span><span style=3D"co=
lor:rgb(0,0,0)"><br></span><span style=3D"color:rgb(0,0,136)">private</span=
><span style=3D"color:rgb(102,102,0)">:</span><span style=3D"color:rgb(0,0,=
0)"><br> </span><span style=3D"color:rgb(0,0,136)">int</span><=
span style=3D"color:rgb(0,0,0)"> a_</span><span style=3D"color:rgb(102,102,=
0)">;</span><span style=3D"color:rgb(0,0,0)"><br> </span><span=
style=3D"color:rgb(0,0,136)">int</span><span style=3D"color:rgb(0,0,0)"> b=
_</span><span style=3D"color:rgb(102,102,0)">;</span><span style=3D"color:r=
gb(0,0,0)"><br> </span><span style=3D"color:rgb(0,0,136)">int<=
/span><span style=3D"color:rgb(0,0,0)"> c_</span><span style=3D"color:rgb(1=
02,102,0)">;</span><span style=3D"color:rgb(0,0,0)"><br></span><span style=
=3D"color:rgb(102,102,0)">};</span><span style=3D"color:rgb(0,0,0)"><br><br=
></span></div></code></div><span style=3D"color:rgb(0,0,0)"><br></span></di=
v></blockquote></code><blockquote class=3D"gmail_quote" style=3D"margin:0px=
0px 0px 0.8ex;padding-left:1ex;border-left-color:rgb(204,204,204);border-l=
eft-width:1px;border-left-style:solid"><div dir=3D"ltr"><br></div></blockqu=
ote></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_527_528104201.1431523475058--
------=_Part_526_225167745.1431523475058--
.
Author: vityatheboss@gmail.com
Date: Wed, 13 May 2015 06:29:10 -0700 (PDT)
Raw View
------=_Part_376_1537677986.1431523750474
Content-Type: multipart/alternative;
boundary="----=_Part_377_935702704.1431523750474"
------=_Part_377_935702704.1431523750474
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
Of course and I understand your response. But you can't force everyone to=
=20
write good code, moreover, you can't guarantee that no one other will look=
=20
and modify your code. In this case you'll be in bad situation again -=20
you've wrote good code, but someone modified it and you don't know where=20
the object attribute changes - you must reread your own fully method again,=
=20
even if you wrote it few years ago and don't remember it.
About extracting of functionality - it means refactoring and it needs time,=
=20
research and full understanding of the code and it's using in the whole=20
program. It costs money, it costs time and it costs nerves.
=D1=81=D1=80=D0=B5=D0=B4=D0=B0, 13 =D0=BC=D0=B0=D1=8F 2015 =D0=B3., 16:04:2=
5 UTC+3 =D0=BF=D0=BE=D0=BB=D1=8C=D0=B7=D0=BE=D0=B2=D0=B0=D1=82=D0=B5=D0=BB=
=D1=8C Andrey Semashev =D0=BD=D0=B0=D0=BF=D0=B8=D1=81=D0=B0=D0=BB:
>
> On Wed, May 13, 2015 at 2:20 PM, <vityat...@gmail.com <javascript:>>=20
> wrote:=20
> > It is good to know what class attributes can be changed in the non-cons=
t=20
> > method:=20
> >=20
> > class A {=20
> > public:=20
> >=20
> > @modify(a_)=20
> > void f() {=20
> > a_ =3D b_ + c_;=20
> > }=20
> > private:=20
> > int a_;=20
> > int b_;=20
> > int c_;=20
> > };=20
> >=20
> >=20
> >=20
> > In this case we can be sure that the method does not change any other=
=20
> > attribute of the object. In this example it may not be much useful but=
=20
> in=20
> > large methods it is very useful in my opinion.=20
>
> I think it is better to design the class and method properly. Maybe=20
> extract a portion of functionality to a separate class/function with a=20
> well defined interface.=20
>
--=20
---=20
You received this message because you are subscribed to the Google Groups "=
ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposa=
ls/.
------=_Part_377_935702704.1431523750474
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr">Of course and I understand your response. But you can't fo=
rce everyone to write good code, moreover, you can't guarantee that no one =
other will look and modify your code. In this case you'll be in bad situati=
on again - you've wrote good code, but someone modified it and you don't kn=
ow where the object attribute changes - you must reread your own fully meth=
od again, even if you wrote it few years ago and don't remember it.<br><br>=
About extracting of functionality - it means refactoring and it needs time,=
research and full understanding of the code and it's using in the whole pr=
ogram. It costs money, it costs time and it costs nerves.<br><br>=D1=81=D1=
=80=D0=B5=D0=B4=D0=B0, 13 =D0=BC=D0=B0=D1=8F 2015 =D0=B3., 16:04:25 UTC+3 =
=D0=BF=D0=BE=D0=BB=D1=8C=D0=B7=D0=BE=D0=B2=D0=B0=D1=82=D0=B5=D0=BB=D1=8C An=
drey Semashev =D0=BD=D0=B0=D0=BF=D0=B8=D1=81=D0=B0=D0=BB:<blockquote class=
=3D"gmail_quote" style=3D"margin: 0;margin-left: 0.8ex;border-left: 1px #cc=
c solid;padding-left: 1ex;">On Wed, May 13, 2015 at 2:20 PM, <<a h=
ref=3D"javascript:" target=3D"_blank" gdf-obfuscated-mailto=3D"xroNpZgTCtEJ=
" rel=3D"nofollow" onmousedown=3D"this.href=3D'javascript:';return true;" o=
nclick=3D"this.href=3D'javascript:';return true;">vityat...@gmail.com</a>&g=
t; wrote:
<br>> It is good to know what class attributes can be changed in the non=
-const
<br>> method:
<br>>
<br>> class A {
<br>> public:
<br>>
<br>> @modify(a_)
<br>> void f() {
<br>> a_ =3D b_ + c_;
<br>> }
<br>> private:
<br>> int a_;
<br>> int b_;
<br>> int c_;
<br>> };
<br>>
<br>>
<br>>
<br>> In this case we can be sure that the method does not change any ot=
her
<br>> attribute of the object. In this example it may not be much useful=
but in
<br>> large methods it is very useful in my opinion.
<br>
<br>I think it is better to design the class and method properly. Maybe
<br>extract a portion of functionality to a separate class/function with a
<br>well defined interface.
<br></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_377_935702704.1431523750474--
------=_Part_376_1537677986.1431523750474--
.
Author: Pablo Oliva <pabloliva87@gmail.com>
Date: Wed, 13 May 2015 10:41:34 -0300
Raw View
--001a11c1fc58f4b29d0515f6c4b8
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
Maybe it's bikeshedding, but I think that this proposal would stand a
better chance of success if it used C++ 11 attributes (I'm guessing
something like
[[modifies: a_]]
for your first example) rather than introducing yet more syntax.
Like it has been previously said here, I'm not sure if it would be
necessary in modular and well designed code. But it would be a useful tool
when trying to limit the impact of a method in a code base that isn't
modular nor well designed.
2015-05-13 10:29 GMT-03:00 <vityatheboss@gmail.com>:
> Of course and I understand your response. But you can't force everyone to
> write good code, moreover, you can't guarantee that no one other will loo=
k
> and modify your code. In this case you'll be in bad situation again -
> you've wrote good code, but someone modified it and you don't know where
> the object attribute changes - you must reread your own fully method agai=
n,
> even if you wrote it few years ago and don't remember it.
>
> About extracting of functionality - it means refactoring and it needs
> time, research and full understanding of the code and it's using in the
> whole program. It costs money, it costs time and it costs nerves.
>
> =D1=81=D1=80=D0=B5=D0=B4=D0=B0, 13 =D0=BC=D0=B0=D1=8F 2015 =D0=B3., 16:04=
:25 UTC+3 =D0=BF=D0=BE=D0=BB=D1=8C=D0=B7=D0=BE=D0=B2=D0=B0=D1=82=D0=B5=D0=
=BB=D1=8C Andrey Semashev =D0=BD=D0=B0=D0=BF=D0=B8=D1=81=D0=B0=D0=BB:
>
>> On Wed, May 13, 2015 at 2:20 PM, <vityat...@gmail.com> wrote:
>> > It is good to know what class attributes can be changed in the
>> non-const
>> > method:
>> >
>> > class A {
>> > public:
>> >
>> > @modify(a_)
>> > void f() {
>> > a_ =3D b_ + c_;
>> > }
>> > private:
>> > int a_;
>> > int b_;
>> > int c_;
>> > };
>> >
>> >
>> >
>> > In this case we can be sure that the method does not change any other
>> > attribute of the object. In this example it may not be much useful but
>> in
>> > large methods it is very useful in my opinion.
>>
>> I think it is better to design the class and method properly. Maybe
>> extract a portion of functionality to a separate class/function with a
>> well defined interface.
>>
> --
>
> ---
> 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/.
>
--=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/.
--001a11c1fc58f4b29d0515f6c4b8
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr">Maybe it's bikeshedding, but I think that this proposa=
l would stand a better chance of success if it used C++ 11 attributes (I=
9;m guessing something like<div>[[modifies: a_]]</div><div>for your first e=
xample) rather than introducing yet more syntax.<div><br></div><div>Like it=
has been previously said here, I'm not sure if it would be necessary i=
n modular and well designed code. But it would be a useful tool when trying=
to limit the impact of a method in a code base that isn't modular nor =
well designed.</div></div></div><div class=3D"gmail_extra"><br><div class=
=3D"gmail_quote">2015-05-13 10:29 GMT-03:00 <span dir=3D"ltr"><<a href=
=3D"mailto:vityatheboss@gmail.com" target=3D"_blank">vityatheboss@gmail.com=
</a>></span>:<br><blockquote class=3D"gmail_quote" style=3D"margin:0 0 0=
.8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir=3D"ltr">Of cour=
se and I understand your response. But you can't force everyone to writ=
e good code, moreover, you can't guarantee that no one other will look =
and modify your code. In this case you'll be in bad situation again - y=
ou've wrote good code, but someone modified it and you don't know w=
here the object attribute changes - you must reread your own fully method a=
gain, even if you wrote it few years ago and don't remember it.<br><br>=
About extracting of functionality - it means refactoring and it needs time,=
research and full understanding of the code and it's using in the whol=
e program. It costs money, it costs time and it costs nerves.<br><br>=D1=81=
=D1=80=D0=B5=D0=B4=D0=B0, 13 =D0=BC=D0=B0=D1=8F 2015 =D0=B3., 16:04:25 UTC+=
3 =D0=BF=D0=BE=D0=BB=D1=8C=D0=B7=D0=BE=D0=B2=D0=B0=D1=82=D0=B5=D0=BB=D1=8C =
Andrey Semashev =D0=BD=D0=B0=D0=BF=D0=B8=D1=81=D0=B0=D0=BB:<div><div class=
=3D"h5"><blockquote class=3D"gmail_quote" style=3D"margin:0;margin-left:0.8=
ex;border-left:1px #ccc solid;padding-left:1ex">On Wed, May 13, 2015 at 2:2=
0 PM, =C2=A0<<a rel=3D"nofollow">vityat...@gmail.com</a>> wrote:
<br>> It is good to know what class attributes can be changed in the non=
-const
<br>> method:
<br>>
<br>> class A {
<br>> public:
<br>>
<br>> @modify(a_)
<br>> void f() {
<br>> =C2=A0 =C2=A0 a_ =3D b_ + c_;
<br>> }
<br>> private:
<br>> =C2=A0 =C2=A0 int a_;
<br>> =C2=A0 =C2=A0 int b_;
<br>> =C2=A0 =C2=A0 int c_;
<br>> };
<br>>
<br>>
<br>>
<br>> In this case we can be sure that the method does not change any ot=
her
<br>> attribute of the object. In this example it may not be much useful=
but in
<br>> large methods it is very useful in my opinion.
<br>
<br>I think it is better to design the class and method properly. Maybe
<br>extract a portion of functionality to a separate class/function with a
<br>well defined interface.
<br></blockquote></div></div></div><div class=3D"HOEnZb"><div class=3D"h5">
<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" target=3D"_=
blank">std-proposals+unsubscribe@isocpp.org</a>.<br>
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org" target=3D"_blank">std-proposals@isocpp.org</a>.<br>
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/" target=3D"_blank">http://groups.google.com/a/isocpp.org/gro=
up/std-proposals/</a>.<br>
</div></div></blockquote></div><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 />
--001a11c1fc58f4b29d0515f6c4b8--
.
Author: Andrey Semashev <andrey.semashev@gmail.com>
Date: Wed, 13 May 2015 16:45:48 +0300
Raw View
On Wed, May 13, 2015 at 4:29 PM, <vityatheboss@gmail.com> wrote:
> Of course and I understand your response. But you can't force everyone to
> write good code, moreover, you can't guarantee that no one other will look
> and modify your code. In this case you'll be in bad situation again - you've
> wrote good code, but someone modified it and you don't know where the object
> attribute changes - you must reread your own fully method again, even if you
> wrote it few years ago and don't remember it.
Code review helps with this.
> About extracting of functionality - it means refactoring and it needs time,
> research and full understanding of the code and it's using in the whole
> program. It costs money, it costs time and it costs nerves.
IMO, this time and effort will be well spent. The end result will be
much better than with your proposed markup. You still have to
understand why and how these data members are changed, including by
the second tier function calls. The markup would have to include all
members which can directly or indirectly be changed by the function:
class A {
public:
void foo() mutable(a_, b_) {
a_ = 42;
bar(); // changes b_; this leaks into foo() declaration
}
void bar() mutable(b_);
private:
int a_, b_;
};
Note that when bar() is changed so that it starts to modify a
different set of variables (e.g. a newly introduced int c_) it breaks
foo() and all other functions that call it, even though bar()'s
interface haven't changed. In the end this will make the class
unmaintainable. Also note that a_, b_, etc. are private but still have
to be specified in the function interface. This leaks the
implementation detail into the class interface.
--
---
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/.
.
Author: vityatheboss@gmail.com
Date: Wed, 13 May 2015 07:15:27 -0700 (PDT)
Raw View
------=_Part_7347_1871656514.1431526527718
Content-Type: multipart/alternative;
boundary="----=_Part_7348_590569542.1431526527718"
------=_Part_7348_590569542.1431526527718
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
You misunderstood me a bit :) I don't say this option must have each method=
=20
declaration. I say if c++1y will have such optional keyword it would be=20
nice.
I understand your point about keyword inheritance and honestly I forgot=20
about that. You are right about that and I did not devise a workaround for=
=20
that. But now I can say following solution:
Marking "mutable" means compiler checking of attribute change only in this=
=20
method, not in the methods inside this current method.
Yes, I am not really serious about this "solution". I'll take some more=20
time in thinking how not to make code worse with this if it is possible.
Also we may invent "immutable" keyword ;)
Of course I am not really serious but I think we may discuss it. I still=20
think when you have no much time to refactor the code, or ("put here any=20
other use of the keyword") it is good to have it. Just exactly similar to=
=20
"override" keyword - optional, but helps if exists (and if it is not large=
=20
in the case of our "mutable" keyword).
=D1=81=D1=80=D0=B5=D0=B4=D0=B0, 13 =D0=BC=D0=B0=D1=8F 2015 =D0=B3., 16:45:4=
9 UTC+3 =D0=BF=D0=BE=D0=BB=D1=8C=D0=B7=D0=BE=D0=B2=D0=B0=D1=82=D0=B5=D0=BB=
=D1=8C Andrey Semashev =D0=BD=D0=B0=D0=BF=D0=B8=D1=81=D0=B0=D0=BB:
>
> On Wed, May 13, 2015 at 4:29 PM, <vityat...@gmail.com <javascript:>>=20
> wrote:=20
> > Of course and I understand your response. But you can't force everyone=
=20
> to=20
> > write good code, moreover, you can't guarantee that no one other will=
=20
> look=20
> > and modify your code. In this case you'll be in bad situation again -=
=20
> you've=20
> > wrote good code, but someone modified it and you don't know where the=
=20
> object=20
> > attribute changes - you must reread your own fully method again, even i=
f=20
> you=20
> > wrote it few years ago and don't remember it.=20
>
> Code review helps with this.=20
>
> > About extracting of functionality - it means refactoring and it needs=
=20
> time,=20
> > research and full understanding of the code and it's using in the whole=
=20
> > program. It costs money, it costs time and it costs nerves.=20
>
> IMO, this time and effort will be well spent. The end result will be=20
> much better than with your proposed markup. You still have to=20
> understand why and how these data members are changed, including by=20
> the second tier function calls. The markup would have to include all=20
> members which can directly or indirectly be changed by the function:=20
>
> class A {=20
> public:=20
> void foo() mutable(a_, b_) {=20
> a_ =3D 42;=20
> bar(); // changes b_; this leaks into foo() declaration=20
> }=20
>
> void bar() mutable(b_);=20
>
> private:=20
> int a_, b_;=20
> };=20
>
> Note that when bar() is changed so that it starts to modify a=20
> different set of variables (e.g. a newly introduced int c_) it breaks=20
> foo() and all other functions that call it, even though bar()'s=20
> interface haven't changed. In the end this will make the class=20
> unmaintainable. Also note that a_, b_, etc. are private but still have=20
> to be specified in the function interface. This leaks the=20
> implementation detail into the class interface.=20
>
--=20
---=20
You received this message because you are subscribed to the Google Groups "=
ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposa=
ls/.
------=_Part_7348_590569542.1431526527718
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr">You misunderstood me a bit :) I don't say this option must=
have each method declaration. I say if c++1y will have such optional keywo=
rd it would be nice.<br><br>I understand your point about keyword inheritan=
ce and honestly I forgot about that. You are right about that and I did not=
devise a workaround for that. But now I can say following solution:<br><br=
><div style=3D"margin-left: 40px;">Marking "mutable" means compiler checkin=
g of attribute change only in this method, not in the methods inside this c=
urrent method.<br></div><br>Yes, I am not really serious about this "soluti=
on". I'll take some more time in thinking how not to make code worse with t=
his if it is possible.<br>Also we may invent "immutable" keyword ;)<br>Of c=
ourse I am not really serious but I think we may discuss it. I still think =
when you have no much time to refactor the code, or ("put here any other us=
e of the keyword") it is good to have it. Just exactly similar to "override=
" keyword - optional, but helps if exists (and if it is not large in the ca=
se of our "mutable" keyword).<br><br>=D1=81=D1=80=D0=B5=D0=B4=D0=B0, 13 =D0=
=BC=D0=B0=D1=8F 2015 =D0=B3., 16:45:49 UTC+3 =D0=BF=D0=BE=D0=BB=D1=8C=D0=B7=
=D0=BE=D0=B2=D0=B0=D1=82=D0=B5=D0=BB=D1=8C Andrey Semashev =D0=BD=D0=B0=D0=
=BF=D0=B8=D1=81=D0=B0=D0=BB:<blockquote class=3D"gmail_quote" style=3D"marg=
in: 0;margin-left: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;">On=
Wed, May 13, 2015 at 4:29 PM, <<a href=3D"javascript:" target=3D"=
_blank" gdf-obfuscated-mailto=3D"yuIc65hkSLcJ" rel=3D"nofollow" onmousedown=
=3D"this.href=3D'javascript:';return true;" onclick=3D"this.href=3D'javascr=
ipt:';return true;">vityat...@gmail.com</a>> wrote:
<br>> Of course and I understand your response. But you can't force ever=
yone to
<br>> write good code, moreover, you can't guarantee that no one other w=
ill look
<br>> and modify your code. In this case you'll be in bad situation agai=
n - you've
<br>> wrote good code, but someone modified it and you don't know where =
the object
<br>> attribute changes - you must reread your own fully method again, e=
ven if you
<br>> wrote it few years ago and don't remember it.
<br>
<br>Code review helps with this.
<br>
<br>> About extracting of functionality - it means refactoring and it ne=
eds time,
<br>> research and full understanding of the code and it's using in the =
whole
<br>> program. It costs money, it costs time and it costs nerves.
<br>
<br>IMO, this time and effort will be well spent. The end result will be
<br>much better than with your proposed markup. You still have to
<br>understand why and how these data members are changed, including by
<br>the second tier function calls. The markup would have to include all
<br>members which can directly or indirectly be changed by the function:
<br>
<br> class A {
<br> public:
<br> void foo() mutable(a_, b_) {
<br> a_ =3D 42;
<br> bar(); // changes b_; this leaks into foo() declar=
ation
<br> }
<br>
<br> void bar() mutable(b_);
<br>
<br> private:
<br> int a_, b_;
<br> };
<br>
<br>Note that when bar() is changed so that it starts to modify a
<br>different set of variables (e.g. a newly introduced int c_) it breaks
<br>foo() and all other functions that call it, even though bar()'s
<br>interface haven't changed. In the end this will make the class
<br>unmaintainable. Also note that a_, b_, etc. are private but still have
<br>to be specified in the function interface. This leaks the
<br>implementation detail into the class interface.
<br></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_7348_590569542.1431526527718--
------=_Part_7347_1871656514.1431526527718--
.
Author: vityatheboss@gmail.com
Date: Wed, 13 May 2015 07:18:45 -0700 (PDT)
Raw View
------=_Part_7719_312276193.1431526725457
Content-Type: multipart/alternative;
boundary="----=_Part_7720_2123426130.1431526725457"
------=_Part_7720_2123426130.1431526725457
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
I don't really care about how this keyword or functionality will be=20
implemented in the language/compilers but I want this functionality because=
=20
I have access to some code which has really large methods and it needs a=20
lot of time into looking the code and writing out the object attributes=20
that were changed there.
I understand that it is not really necessary in well designed code but we=
=20
don't have well designed code all the time. I think, you agree with that.
=D1=81=D1=80=D0=B5=D0=B4=D0=B0, 13 =D0=BC=D0=B0=D1=8F 2015 =D0=B3., 16:41:3=
5 UTC+3 =D0=BF=D0=BE=D0=BB=D1=8C=D0=B7=D0=BE=D0=B2=D0=B0=D1=82=D0=B5=D0=BB=
=D1=8C Pablo Oliva =D0=BD=D0=B0=D0=BF=D0=B8=D1=81=D0=B0=D0=BB:
>
> Maybe it's bikeshedding, but I think that this proposal would stand a=20
> better chance of success if it used C++ 11 attributes (I'm guessing=20
> something like
> [[modifies: a_]]
> for your first example) rather than introducing yet more syntax.
>
> Like it has been previously said here, I'm not sure if it would be=20
> necessary in modular and well designed code. But it would be a useful too=
l=20
> when trying to limit the impact of a method in a code base that isn't=20
> modular nor well designed.
>
> 2015-05-13 10:29 GMT-03:00 <vityat...@gmail.com <javascript:>>:
>
>> Of course and I understand your response. But you can't force everyone t=
o=20
>> write good code, moreover, you can't guarantee that no one other will lo=
ok=20
>> and modify your code. In this case you'll be in bad situation again -=20
>> you've wrote good code, but someone modified it and you don't know where=
=20
>> the object attribute changes - you must reread your own fully method aga=
in,=20
>> even if you wrote it few years ago and don't remember it.
>>
>> About extracting of functionality - it means refactoring and it needs=20
>> time, research and full understanding of the code and it's using in the=
=20
>> whole program. It costs money, it costs time and it costs nerves.
>>
>> =D1=81=D1=80=D0=B5=D0=B4=D0=B0, 13 =D0=BC=D0=B0=D1=8F 2015 =D0=B3., 16:0=
4:25 UTC+3 =D0=BF=D0=BE=D0=BB=D1=8C=D0=B7=D0=BE=D0=B2=D0=B0=D1=82=D0=B5=D0=
=BB=D1=8C Andrey Semashev=20
>> =D0=BD=D0=B0=D0=BF=D0=B8=D1=81=D0=B0=D0=BB:
>>
>>> On Wed, May 13, 2015 at 2:20 PM, <vityat...@gmail.com> wrote:=20
>>> > It is good to know what class attributes can be changed in the=20
>>> non-const=20
>>> > method:=20
>>> >=20
>>> > class A {=20
>>> > public:=20
>>> >=20
>>> > @modify(a_)=20
>>> > void f() {=20
>>> > a_ =3D b_ + c_;=20
>>> > }=20
>>> > private:=20
>>> > int a_;=20
>>> > int b_;=20
>>> > int c_;=20
>>> > };=20
>>> >=20
>>> >=20
>>> >=20
>>> > In this case we can be sure that the method does not change any other=
=20
>>> > attribute of the object. In this example it may not be much useful bu=
t=20
>>> in=20
>>> > large methods it is very useful in my opinion.=20
>>>
>>> I think it is better to design the class and method properly. Maybe=20
>>> extract a portion of functionality to a separate class/function with a=
=20
>>> well defined interface.=20
>>>
>> --=20
>>
>> ---=20
>> You received this message because you are subscribed to the Google Group=
s=20
>> "ISO C++ Standard - Future Proposals" group.
>> To unsubscribe from this group and stop receiving emails from it, send a=
n=20
>> email to std-proposal...@isocpp.org <javascript:>.
>> To post to this group, send email to std-pr...@isocpp.org <javascript:>.
>> Visit this group at=20
>> http://groups.google.com/a/isocpp.org/group/std-proposals/.
>>
>
>
--=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_7720_2123426130.1431526725457
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr">I don't really care about how this keyword or functionalit=
y will be implemented in the language/compilers but I want this functionali=
ty because I have access to some code which has really large methods and it=
needs a lot of time into looking the code and writing out the object attri=
butes that were changed there.<br><br>I understand that it is not really ne=
cessary in well designed code but we don't have well designed code all the =
time. I think, you agree with that.<br><br>=D1=81=D1=80=D0=B5=D0=B4=D0=B0, =
13 =D0=BC=D0=B0=D1=8F 2015 =D0=B3., 16:41:35 UTC+3 =D0=BF=D0=BE=D0=BB=D1=8C=
=D0=B7=D0=BE=D0=B2=D0=B0=D1=82=D0=B5=D0=BB=D1=8C Pablo Oliva =D0=BD=D0=B0=
=D0=BF=D0=B8=D1=81=D0=B0=D0=BB:<blockquote class=3D"gmail_quote" style=3D"m=
argin: 0;margin-left: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;"=
><div dir=3D"ltr">Maybe it's bikeshedding, but I think that this proposal w=
ould stand a better chance of success if it used C++ 11 attributes (I'm gue=
ssing something like<div>[[modifies: a_]]</div><div>for your first example)=
rather than introducing yet more syntax.<div><br></div><div>Like it has be=
en previously said here, I'm not sure if it would be necessary in modular a=
nd well designed code. But it would be a useful tool when trying to limit t=
he impact of a method in a code base that isn't modular nor well designed.<=
/div></div></div><div><br><div class=3D"gmail_quote">2015-05-13 10:29 GMT-0=
3:00 <span dir=3D"ltr"><<a href=3D"javascript:" target=3D"_blank" gdf-o=
bfuscated-mailto=3D"JdC62UvOiUQJ" rel=3D"nofollow" onmousedown=3D"this.href=
=3D'javascript:';return true;" onclick=3D"this.href=3D'javascript:';return =
true;">vityat...@gmail.com</a>></span>:<br><blockquote class=3D"gmail_qu=
ote" style=3D"margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex=
"><div dir=3D"ltr">Of course and I understand your response. But you can't =
force everyone to write good code, moreover, you can't guarantee that no on=
e other will look and modify your code. In this case you'll be in bad situa=
tion again - you've wrote good code, but someone modified it and you don't =
know where the object attribute changes - you must reread your own fully me=
thod again, even if you wrote it few years ago and don't remember it.<br><b=
r>About extracting of functionality - it means refactoring and it needs tim=
e, research and full understanding of the code and it's using in the whole =
program. It costs money, it costs time and it costs nerves.<br><br>=D1=81=
=D1=80=D0=B5=D0=B4=D0=B0, 13 =D0=BC=D0=B0=D1=8F 2015 =D0=B3., 16:04:25 UTC+=
3 =D0=BF=D0=BE=D0=BB=D1=8C=D0=B7=D0=BE=D0=B2=D0=B0=D1=82=D0=B5=D0=BB=D1=8C =
Andrey Semashev =D0=BD=D0=B0=D0=BF=D0=B8=D1=81=D0=B0=D0=BB:<div><div><block=
quote class=3D"gmail_quote" style=3D"margin:0;margin-left:0.8ex;border-left=
:1px #ccc solid;padding-left:1ex">On Wed, May 13, 2015 at 2:20 PM, &l=
t;<a rel=3D"nofollow">vityat...@gmail.com</a>> wrote:
<br>> It is good to know what class attributes can be changed in the non=
-const
<br>> method:
<br>>
<br>> class A {
<br>> public:
<br>>
<br>> @modify(a_)
<br>> void f() {
<br>> a_ =3D b_ + c_;
<br>> }
<br>> private:
<br>> int a_;
<br>> int b_;
<br>> int c_;
<br>> };
<br>>
<br>>
<br>>
<br>> In this case we can be sure that the method does not change any ot=
her
<br>> attribute of the object. In this example it may not be much useful=
but in
<br>> large methods it is very useful in my opinion.
<br>
<br>I think it is better to design the class and method properly. Maybe
<br>extract a portion of functionality to a separate class/function with a
<br>well defined interface.
<br></blockquote></div></div></div><div><div>
<p></p>
-- <br>
<br>
--- <br>
You received this message because you are subscribed to the Google Groups "=
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"javascript:" target=3D"_blank" gdf-obfuscated-mailto=3D"=
JdC62UvOiUQJ" rel=3D"nofollow" onmousedown=3D"this.href=3D'javascript:';ret=
urn true;" onclick=3D"this.href=3D'javascript:';return true;">std-proposal.=
...@<wbr>isocpp.org</a>.<br>
To post to this group, send email to <a href=3D"javascript:" target=3D"_bla=
nk" gdf-obfuscated-mailto=3D"JdC62UvOiUQJ" rel=3D"nofollow" onmousedown=3D"=
this.href=3D'javascript:';return true;" onclick=3D"this.href=3D'javascript:=
';return true;">std-pr...@isocpp.org</a>.<br>
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/" target=3D"_blank" rel=3D"nofollow" onmousedown=3D"this.href=
=3D'http://groups.google.com/a/isocpp.org/group/std-proposals/';return true=
;" onclick=3D"this.href=3D'http://groups.google.com/a/isocpp.org/group/std-=
proposals/';return true;">http://groups.google.com/a/<wbr>isocpp.org/group/=
std-<wbr>proposals/</a>.<br>
</div></div></blockquote></div><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_7720_2123426130.1431526725457--
------=_Part_7719_312276193.1431526725457--
.
Author: Nicol Bolas <jmckesson@gmail.com>
Date: Wed, 13 May 2015 07:20:49 -0700 (PDT)
Raw View
------=_Part_197_1335827946.1431526849845
Content-Type: multipart/alternative;
boundary="----=_Part_198_1466242684.1431526849845"
------=_Part_198_1466242684.1431526849845
Content-Type: text/plain; charset=UTF-8
On Wednesday, May 13, 2015 at 9:45:49 AM UTC-4, Andrey Semashev wrote:
>
> On Wed, May 13, 2015 at 4:29 PM, <vityat...@gmail.com <javascript:>>
> wrote:
> > Of course and I understand your response. But you can't force everyone
> to
> > write good code, moreover, you can't guarantee that no one other will
> look
> > and modify your code. In this case you'll be in bad situation again -
> you've
> > wrote good code, but someone modified it and you don't know where the
> object
> > attribute changes - you must reread your own fully method again, even if
> you
> > wrote it few years ago and don't remember it.
>
> Code review helps with this.
>
> > About extracting of functionality - it means refactoring and it needs
> time,
> > research and full understanding of the code and it's using in the whole
> > program. It costs money, it costs time and it costs nerves.
>
> IMO, this time and effort will be well spent. The end result will be
> much better than with your proposed markup. You still have to
> understand why and how these data members are changed, including by
> the second tier function calls. The markup would have to include all
> members which can directly or indirectly be changed by the function:
>
> class A {
> public:
> void foo() mutable(a_, b_) {
> a_ = 42;
> bar(); // changes b_; this leaks into foo() declaration
> }
>
> void bar() mutable(b_);
>
> private:
> int a_, b_;
> };
>
> Note that when bar() is changed so that it starts to modify a
> different set of variables (e.g. a newly introduced int c_) it breaks
> foo() and all other functions that call it, even though bar()'s
> interface haven't changed. In the end this will make the class
> unmaintainable. Also note that a_, b_, etc. are private but still have
> to be specified in the function interface. This leaks the
> implementation detail into the class interface.
>
Isn't this the exact same reason why we nobody used `throw` specifiers? And
therefore, we got rid of them?
In any case, this is really just a small part of contract programming,
isn't it?
--
---
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_198_1466242684.1431526849845
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr"><br><br>On Wednesday, May 13, 2015 at 9:45:49 AM UTC-4, An=
drey Semashev wrote:<blockquote class=3D"gmail_quote" style=3D"margin: 0;ma=
rgin-left: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;">On Wed, Ma=
y 13, 2015 at 4:29 PM, <<a href=3D"javascript:" target=3D"_blank" =
gdf-obfuscated-mailto=3D"yuIc65hkSLcJ" rel=3D"nofollow" onmousedown=3D"this=
..href=3D'javascript:';return true;" onclick=3D"this.href=3D'javascript:';re=
turn true;">vityat...@gmail.com</a>> wrote:
<br>> Of course and I understand your response. But you can't force ever=
yone to
<br>> write good code, moreover, you can't guarantee that no one other w=
ill look
<br>> and modify your code. In this case you'll be in bad situation agai=
n - you've
<br>> wrote good code, but someone modified it and you don't know where =
the object
<br>> attribute changes - you must reread your own fully method again, e=
ven if you
<br>> wrote it few years ago and don't remember it.
<br>
<br>Code review helps with this.
<br>
<br>> About extracting of functionality - it means refactoring and it ne=
eds time,
<br>> research and full understanding of the code and it's using in the =
whole
<br>> program. It costs money, it costs time and it costs nerves.
<br>
<br>IMO, this time and effort will be well spent. The end result will be
<br>much better than with your proposed markup. You still have to
<br>understand why and how these data members are changed, including by
<br>the second tier function calls. The markup would have to include all
<br>members which can directly or indirectly be changed by the function:
<br>
<br> class A {
<br> public:
<br> void foo() mutable(a_, b_) {
<br> a_ =3D 42;
<br> bar(); // changes b_; this leaks into foo() declar=
ation
<br> }
<br>
<br> void bar() mutable(b_);
<br>
<br> private:
<br> int a_, b_;
<br> };
<br>
<br>Note that when bar() is changed so that it starts to modify a
<br>different set of variables (e.g. a newly introduced int c_) it breaks
<br>foo() and all other functions that call it, even though bar()'s
<br>interface haven't changed. In the end this will make the class
<br>unmaintainable. Also note that a_, b_, etc. are private but still have
<br>to be specified in the function interface. This leaks the
<br>implementation detail into the class interface.
<br></blockquote><div><br>Isn't this the exact same reason why we nobody us=
ed `throw` specifiers? And therefore, we got rid of them?<br><br>In any cas=
e, this is really just a small part of contract programming, isn't it?<br><=
/div></div>
<p></p>
-- <br />
<br />
--- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals" 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_198_1466242684.1431526849845--
------=_Part_197_1335827946.1431526849845--
.
Author: Nevin Liber <nevin@eviloverlord.com>
Date: Wed, 13 May 2015 09:25:27 -0500
Raw View
--001a113ce04c523ef00515f7647a
Content-Type: text/plain; charset=UTF-8
On 13 May 2015 at 09:18, <vityatheboss@gmail.com> wrote:
> I don't really care about how this keyword or functionality will be
> implemented in the language/compilers but I want this functionality because
> I have access to some code which has really large methods and it needs a
> lot of time into looking the code and writing out the object attributes
> that were changed there.
>
> I understand that it is not really necessary in well designed code but we
> don't have well designed code all the time. I think, you agree with that.
>
And you'd rather spend time sprinkling this keyword everywhere instead of
just making the code better?
--
Nevin ":-)" Liber <mailto:nevin@eviloverlord.com> (847) 691-1404
--
---
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/.
--001a113ce04c523ef00515f7647a
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr"><div class=3D"gmail_extra">On 13 May 2015 at 09:18, <span=
dir=3D"ltr"><<a href=3D"mailto:vityatheboss@gmail.com" target=3D"_blank=
">vityatheboss@gmail.com</a>></span> wrote:<br><div class=3D"gmail_quote=
"><blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:=
1px #ccc solid;padding-left:1ex"><div dir=3D"ltr">I don't really care a=
bout how this keyword or functionality will be implemented in the language/=
compilers but I want this functionality because I have access to some code =
which has really large methods and it needs a lot of time into looking the =
code and writing out the object attributes that were changed there.<br><br>=
I understand that it is not really necessary in well designed code but we d=
on't have well designed code all the time. I think, you agree with that=
..<br></div></blockquote></div><br>And you'd rather spend time sprinklin=
g this keyword everywhere instead of just making the code better?<br>-- <br=
><div class=3D"gmail_signature">=C2=A0Nevin ":-)" Liber=C2=A0 <=
;mailto:<a href=3D"mailto:nevin@eviloverlord.com" target=3D"_blank">nevin@e=
viloverlord.com</a>>=C2=A0 (847) 691-1404</div>
</div></div>
<p></p>
-- <br />
<br />
--- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals" 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 />
--001a113ce04c523ef00515f7647a--
.
Author: Andrey Semashev <andrey.semashev@gmail.com>
Date: Wed, 13 May 2015 17:28:29 +0300
Raw View
On Wed, May 13, 2015 at 5:20 PM, Nicol Bolas <jmckesson@gmail.com> wrote:
> On Wednesday, May 13, 2015 at 9:45:49 AM UTC-4, Andrey Semashev wrote:
>>
>> On Wed, May 13, 2015 at 4:29 PM, <vityat...@gmail.com> wrote:
>> > Of course and I understand your response. But you can't force everyone
>> > to
>> > write good code, moreover, you can't guarantee that no one other will
>> > look
>> > and modify your code. In this case you'll be in bad situation again -
>> > you've
>> > wrote good code, but someone modified it and you don't know where the
>> > object
>> > attribute changes - you must reread your own fully method again, even if
>> > you
>> > wrote it few years ago and don't remember it.
>>
>> Code review helps with this.
>>
>> > About extracting of functionality - it means refactoring and it needs
>> > time,
>> > research and full understanding of the code and it's using in the whole
>> > program. It costs money, it costs time and it costs nerves.
>>
>> IMO, this time and effort will be well spent. The end result will be
>> much better than with your proposed markup. You still have to
>> understand why and how these data members are changed, including by
>> the second tier function calls. The markup would have to include all
>> members which can directly or indirectly be changed by the function:
>>
>> class A {
>> public:
>> void foo() mutable(a_, b_) {
>> a_ = 42;
>> bar(); // changes b_; this leaks into foo() declaration
>> }
>>
>> void bar() mutable(b_);
>>
>> private:
>> int a_, b_;
>> };
>>
>> Note that when bar() is changed so that it starts to modify a
>> different set of variables (e.g. a newly introduced int c_) it breaks
>> foo() and all other functions that call it, even though bar()'s
>> interface haven't changed. In the end this will make the class
>> unmaintainable. Also note that a_, b_, etc. are private but still have
>> to be specified in the function interface. This leaks the
>> implementation detail into the class interface.
>
>
> Isn't this the exact same reason why we nobody used `throw` specifiers? And
> therefore, we got rid of them?
>
> In any case, this is really just a small part of contract programming, isn't
> it?
throw() specifiers are part of the interface (i.e. they specify the
exceptions that can be thrown by the method) and also make sure that
contract is fulfilled in runtime. Personally, I have found throw()
specifiers somewhat useful for that reason. Contrary to that, the
proposed here markup is not part of the interface but is a part of the
implementation. But I agree, the difficulties with throw() specifiers
apply here as well.
--
---
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/.
.
Author: Andrey Semashev <andrey.semashev@gmail.com>
Date: Wed, 13 May 2015 17:35:29 +0300
Raw View
On Wed, May 13, 2015 at 5:15 PM, <vityatheboss@gmail.com> wrote:
> You misunderstood me a bit :) I don't say this option must have each method
> declaration.
No, I had that in mind. At the very least, the markup must be optional
for backward compatibility.
> I understand your point about keyword inheritance and honestly I forgot
> about that. You are right about that and I did not devise a workaround for
> that. But now I can say following solution:
>
> Marking "mutable" means compiler checking of attribute change only in this
> method, not in the methods inside this current method.
I think that pretty much defeats the whole purpose of this markup. You
can no longer tell which members can change as a result of calling a
method.
--
---
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/.
.
Author: mash.boyko2014@gmail.com
Date: Wed, 13 May 2015 07:38:27 -0700 (PDT)
Raw View
------=_Part_18_1805973401.1431527907602
Content-Type: multipart/alternative;
boundary="----=_Part_19_1316260187.1431527907606"
------=_Part_19_1316260187.1431527907606
Content-Type: text/plain; charset=UTF-8
Would it be part of the function interface if the data was public instead
of private?
--
---
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_19_1316260187.1431527907606
Content-Type: text/html; charset=UTF-8
<div dir="ltr">Would it be part of the function interface if the data was public instead of private?</div>
<p></p>
-- <br />
<br />
--- <br />
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.<br />
To unsubscribe from this group and stop receiving emails from it, send an email to <a href="mailto:std-proposals+unsubscribe@isocpp.org">std-proposals+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href="mailto:std-proposals@isocpp.org">std-proposals@isocpp.org</a>.<br />
Visit this group at <a href="http://groups.google.com/a/isocpp.org/group/std-proposals/">http://groups.google.com/a/isocpp.org/group/std-proposals/</a>.<br />
------=_Part_19_1316260187.1431527907606--
------=_Part_18_1805973401.1431527907602--
.
Author: David Krauss <potswa@mac.com>
Date: Fri, 15 May 2015 00:06:22 +0800
Raw View
--Apple-Mail=_E49BEEB8-2A65-4877-99DF-BBA319BB0100
Content-Transfer-Encoding: quoted-printable
Content-Type: text/plain; charset=UTF-8
> On 2015=E2=80=9305=E2=80=9314, at 7:16 PM, Douglas Boffey <douglas.boffey=
@gmail.com <mailto:douglas.boffey@gmail.com>> wrote:
>=20
> There is, of course, the inverse idea=E2=80=94explicitly indicate which
> members are const.
>=20
> class Foo {
> int i_will_change;
> int i_will_not;
> public:
> void bar() const(i_will_not);
> };
Or provide an always-const access path as a member.
class Foo {
// Give actual state a new, inconvenient name:
int i_will_change;
// Crufty functions and lazy programmers get read-only access, through the=
old name:
int const & i =3D i_will_change;
};
=E2=80=9CExpression aliases=E2=80=9D would be a more powerful form of this,=
useful not only for cleaning up extremely crufty code, but also for migrat=
ing struct-like aggregate interfaces to use encapsulated state.
Aside: Suggestions for expression alias syntax would be welcome. One sugges=
tion is =E2=80=9Cusing=E2=80=9D declarations, but=E2=80=A6
1. There=E2=80=99s no room to mention a type for the sake of class interfac=
e documentation.
2. If you use a cast to mention a type, you have the choice between a verbo=
se static_cast or an unsafe C cast. Either way, explicit conversions are in=
advertently enabled.
3. It=E2=80=99s hard to differentiate from a type declaration, especially i=
n a template context.
4. It doesn=E2=80=99t fit as a parameter declaration. It would be useful to=
capture an expression from the caller=E2=80=99s context into an always-inl=
ine function.
The committee has expressed a preference for something that doesn=E2=80=99t=
look like a variable declaration. So, I=E2=80=99m looking for something th=
at fits into a variable declaration slot, but looks very distinct.
--=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/.
--Apple-Mail=_E49BEEB8-2A65-4877-99DF-BBA319BB0100
Content-Transfer-Encoding: quoted-printable
Content-Type: text/html; charset=UTF-8
<html><head><meta http-equiv=3D"Content-Type" content=3D"text/html charset=
=3Dutf-8"><meta http-equiv=3D"Content-Type" content=3D"text/html charset=3D=
utf-8"></head><body style=3D"word-wrap: break-word; -webkit-nbsp-mode: spac=
e; -webkit-line-break: after-white-space;" class=3D""><br class=3D""><div c=
lass=3D""><blockquote type=3D"cite" class=3D""><div class=3D"">On 2015=E2=
=80=9305=E2=80=9314, at 7:16 PM, Douglas Boffey <<a href=3D"mailto:dougl=
as.boffey@gmail.com" class=3D"">douglas.boffey@gmail.com</a>> wrote:</di=
v><br class=3D"Apple-interchange-newline"><div class=3D"">There is, of cour=
se, the inverse idea=E2=80=94explicitly indicate which<br class=3D"">member=
s are const.<br class=3D""><br class=3D"">class Foo {<br class=3D""> =
int i_will_change;<br class=3D""> int i_will_not;<br class=3D"">publi=
c:<br class=3D""> void bar() const(i_will_not);<br class=3D"">};<br c=
lass=3D""></div></blockquote></div><br class=3D""><div class=3D"">Or provid=
e an always-const access path as a member.</div><div class=3D""><br class=
=3D""></div><div class=3D""><font face=3D"Courier" class=3D"">class Foo {</=
font></div><div class=3D""><font face=3D"Courier" class=3D""> // Give =
actual state a new, inconvenient name:<br class=3D""> int i_will_chang=
e;</font></div><div class=3D""><font face=3D"Courier" class=3D""><br class=
=3D""></font></div><div class=3D""><font face=3D"Courier" class=3D""> =
// Crufty functions and lazy programmers get read-only access, through the =
old name:<br class=3D""> int const & i =3D i_will_change;</font></=
div><div class=3D""><font face=3D"Courier" class=3D"">};</font></div><div c=
lass=3D""><br class=3D""></div><div class=3D"">=E2=80=9CExpression aliases=
=E2=80=9D would be a more powerful form of this, useful not only for cleani=
ng up extremely crufty code, but also for migrating struct-like aggregate i=
nterfaces to use encapsulated state.</div><div class=3D""><br class=3D""></=
div><div class=3D"">Aside: Suggestions for expression alias syntax would be=
welcome. One suggestion is =E2=80=9C<font face=3D"Courier" class=3D"">usin=
g</font>=E2=80=9D declarations, but=E2=80=A6</div><div class=3D""><br class=
=3D""></div><div class=3D"">1. There=E2=80=99s no room to mention a type fo=
r the sake of class interface documentation.</div><div class=3D"">2. If you=
use a cast to mention a type, you have the choice between a verbose <font =
face=3D"Courier" class=3D"">static_cast</font> or an unsafe C cast. Either =
way, explicit conversions are inadvertently enabled.</div><div class=3D"">3=
.. It=E2=80=99s hard to differentiate from a type declaration, especially in=
a template context.</div><div class=3D"">4. It doesn=E2=80=99t fit as a pa=
rameter declaration. It would be useful to capture an expression from the c=
aller=E2=80=99s context into an always-inline function.</div><div class=3D"=
"><br class=3D""></div><div class=3D"">The committee has expressed a prefer=
ence for something that doesn=E2=80=99t look like a variable declaration. S=
o, I=E2=80=99m looking for something that fits into a variable declaration =
slot, but looks very distinct.</div></body></html>
<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 />
--Apple-Mail=_E49BEEB8-2A65-4877-99DF-BBA319BB0100--
.