Topic: AutoGetSetter Attribute


Author: Matthew Greenwood <matthew.i.greenwood@gmail.com>
Date: Fri, 28 Nov 2014 03:11:48 -0800 (PST)
Raw View
------=_Part_142_1673212520.1417173108090
Content-Type: multipart/alternative;
 boundary="----=_Part_143_384466175.1417173108090"

------=_Part_143_384466175.1417173108090
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable



Hi,


I am new to this forum and wanted to run an idea past you guys which I feel=
=20
could be a good addition to the standard.

Being a newbie here this might have already been discussed in some form or=
=20
maybe even thrown out of the window already.


Where I work we use lots of Data-Only types that have various requirements=
=20
for access requirements.

What I absolutely hate is the need to write all the boiler-plate code that=
=20
in my opinion should be created by the compiler.

Having this done by the compile would not only serve to ensure complete=20
validity in the code. But also to reduce the possible coder errors that=20
could be introduced as well as reducing the number of characters typed.


=E2=80=9CLess code =3D More Software=E2=80=9D


Also having the compiler create the required boiler plate code for us would=
=20
also reduce the need for drastic changes as the compilers are improved. As=
=20
well as allowing the compiler to know the best optimal implementation of=20
what we are defining.


What I am talking about here is what I like to call autoGetSetter=E2=80=99s=
.. The=20
idea was inspired by the auto getter and setters in  dot Net.


Consider the following class definition:


class T
{
public:
 M getMember() const;
 void setMember(M const& value);

 =E2=80=A6 other stuff =E2=80=A6
private:
 M member;
}



no this all looks good an well.

BUT=E2=80=A6

what about c++11 move semantics?


well that would increase our definitions to the following:


class T
{
public:
 M getMember() const;
 void setMember(M const& value);
 void setMember(M&& value);

 =E2=80=A6 other stuff =E2=80=A6
private:
 M member;
}



=E2=80=9COk that looks perfectly fine=E2=80=9D I can hear you saying.


Well that is ok for this simple trivial class.

But what happens when things become a little less simple?

Or another great standard feature s introduced? Maybe the current best=20
practises change and we need to now trawl through all of our code to add=20
=E2=80=9Cnoexcept=E2=80=9D everywhere, or a new =E2=80=9Csuper universal re=
ference=E2=80=9D.

Or even worse, you make a typo in your code and end up chasing your tail=20
with spurious error messages from the compiler? (Which I have done on many=
=20
occasions)

Not to mention the extra (technically unneeded) definition in the cpp files=
..


My problem with this is when you have a dozen or so of these, and their=20
implementations are fairly trivial. Then why can this work not be done by=
=20
the compiler?


What I have currently is a =E2=80=9CPre-Compiler=E2=80=9D process that crea=
tes these on the=20
fly for me. This I think makes it much more simpler to create classes like=
=20
this and also helps to reduce my code bloat. Also I would argue that my new=
=20
definition is more understandable and direct about the intentions of the=20
data it contains.


Here is what my code currently shows.


class T
{
public:
 =E2=80=A6 other stuff =E2=80=A6
private:
 [[public get, private set]] M member;
}



Now just think also of what the cpp file might now contain=E2=80=A6

Only my "*other stuff"*. That's it. Just the important details that are=20
needed for the class.


Now how clean and clear is that?


with this new attribute I can define the following:


[[public get]] or [[get]] or [[public get(default)]] or [[get(default)]] ->=
=20
compiler should generate a default public getter for the data member.

[[private set]] or [[private set(default)]] -> compiler generates a default=
=20
trivial private setter.

[[public set]] or [[public set(default)]] or [[set]] -> compiler generates=
=20
a default trivial prublic setter.

[[public get(delete)]] or [[get(delete)]] -> compiler does not create a=20
getter (same as not defining the attribute at all but more direct about=20
usage to an implementer).

[[public set(delete)]] or [[set(delete)]] -> compiler does not create a=20
setter.

[[get(randomGetterFunc)]] -> compiler names the auto generated function as=
=20
required by the definition.


To define both they only need to be separated by a comma. This attribute=20
should only ever contain a single get and set definition.


I guess the easiest way to describe it is?


[[{public*[=3Ddefault]*|private|protected}=20
{get|set}{(default|deleted|functionName)}{, ...}]]


This is also much easier when writing template classes, as the compiler=20
already knows all the types and their abilities when stamping out specific=
=20
versions.

All in all using our simple =E2=80=9CPre-Compiler=E2=80=9D process I have r=
educed the code=20
base I work on by 25%. Less Typing also means I get an awful lot less bugs=
=20
and more time to drool over the up and coming features of the c++ language=
=20
(and in some cases learn how to use them totally wrong).


This also works well with our "inheritance aliasing". Which is a whole=20
other ball of wax and is already mentioned in another post on here.


I hope this all makes sense and wonder why peoples opinions are about this.


IzzyCoding

"Coding nothing is faster than coding something"


--=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_143_384466175.1417173108090
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><p style=3D"margin-bottom: 0px; font-size: 12px; line-heig=
ht: normal; font-family: Helvetica;">Hi,</p>
<p style=3D"margin-bottom: 0px; font-size: 12px; line-height: normal; font-=
family: Helvetica; min-height: 14px;"><br></p>
<p style=3D"margin-bottom: 0px; font-size: 12px; line-height: normal; font-=
family: Helvetica;">I am new to this forum and wanted to run an idea past y=
ou guys which I feel could be a good addition to the standard.</p>
<p style=3D"margin-bottom: 0px; font-size: 12px; line-height: normal; font-=
family: Helvetica;">Being a newbie here this might have already been discus=
sed in some form or maybe even thrown out of the window already.</p>
<p style=3D"margin-bottom: 0px; font-size: 12px; line-height: normal; font-=
family: Helvetica; min-height: 14px;"><br></p>
<p style=3D"margin-bottom: 0px; font-size: 12px; line-height: normal; font-=
family: Helvetica;">Where I work we use lots of Data-Only types that have v=
arious requirements for access requirements.</p>
<p style=3D"margin-bottom: 0px; font-size: 12px; line-height: normal; font-=
family: Helvetica;">What I absolutely hate is the need to write all the boi=
ler-plate code that in my opinion should be created by the compiler.</p>
<p style=3D"margin-bottom: 0px; font-size: 12px; line-height: normal; font-=
family: Helvetica;">Having this done by the compile would not only serve to=
 ensure complete validity in the code. But also to reduce the possible code=
r errors that could be introduced as well as reducing the number of charact=
ers typed.</p>
<p style=3D"margin-bottom: 0px; font-size: 12px; line-height: normal; font-=
family: Helvetica; min-height: 14px;"><br></p>
<p style=3D"margin-bottom: 0px; font-size: 12px; line-height: normal; font-=
family: Helvetica;">=E2=80=9CLess code =3D More Software=E2=80=9D</p>
<p style=3D"margin-bottom: 0px; font-size: 12px; line-height: normal; font-=
family: Helvetica; min-height: 14px;"><br></p>
<p style=3D"margin-bottom: 0px; font-size: 12px; line-height: normal; font-=
family: Helvetica;">Also having the compiler create the required boiler pla=
te code for us would also reduce the need for drastic changes as the compil=
ers are improved. As well as allowing the compiler to know the best optimal=
 implementation of what we are defining.</p>
<p style=3D"margin-bottom: 0px; font-size: 12px; line-height: normal; font-=
family: Helvetica; min-height: 14px;"><br></p>
<p style=3D"margin-bottom: 0px; font-size: 12px; line-height: normal; font-=
family: Helvetica;">What I am talking about here is what I like to call aut=
oGetSetter=E2=80=99s. The idea was inspired by the auto getter and setters =
in&nbsp; dot Net.</p>
<p style=3D"margin-bottom: 0px; font-size: 12px; line-height: normal; font-=
family: Helvetica; min-height: 14px;"><br></p>
<p style=3D"margin-bottom: 0px; font-size: 12px; line-height: normal; font-=
family: Helvetica;">Consider the following class definition:</p>
<p style=3D"margin-bottom: 0px; font-size: 12px; line-height: normal; font-=
family: Helvetica; min-height: 14px;"><br></p>
<div class=3D"prettyprint" style=3D"background-color: rgb(250, 250, 250); b=
order: 1px solid rgb(187, 187, 187); word-wrap: break-word;"><code class=3D=
"prettyprint"><div class=3D"subprettyprint"><span style=3D"color: #008;" cl=
ass=3D"styled-by-prettify">class</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"> T<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><span style=3D"color: #008;" class=3D"styled-by-prett=
ify">public</span><span style=3D"color: #660;" class=3D"styled-by-prettify"=
>:</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br>&nbs=
p;M getMember</span><span style=3D"color: #660;" class=3D"styled-by-prettif=
y">()</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </sp=
an><span style=3D"color: #008;" class=3D"styled-by-prettify">const</span><s=
pan style=3D"color: #660;" class=3D"styled-by-prettify">;</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"><br>&nbsp;</span><span style=
=3D"color: #008;" class=3D"styled-by-prettify">void</span><span style=3D"co=
lor: #000;" class=3D"styled-by-prettify"> setMember</span><span style=3D"co=
lor: #660;" class=3D"styled-by-prettify">(</span><span style=3D"color: #000=
;" class=3D"styled-by-prettify">M </span><span style=3D"color: #008;" class=
=3D"styled-by-prettify">const</span><span style=3D"color: #660;" class=3D"s=
tyled-by-prettify">&amp;</span><span style=3D"color: #000;" class=3D"styled=
-by-prettify"> value</span><span style=3D"color: #660;" class=3D"styled-by-=
prettify">);</span><span style=3D"color: #000;" class=3D"styled-by-prettify=
"><br><br>&nbsp;</span><span style=3D"color: #660;" class=3D"styled-by-pret=
tify">=E2=80=A6</span><span style=3D"color: #000;" class=3D"styled-by-prett=
ify"> other stuff </span><span style=3D"color: #660;" class=3D"styled-by-pr=
ettify">=E2=80=A6</span><span style=3D"color: #000;" class=3D"styled-by-pre=
ttify"><br></span><span style=3D"color: #008;" class=3D"styled-by-prettify"=
>private</span><span style=3D"color: #660;" class=3D"styled-by-prettify">:<=
/span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br>&nbsp;M=
 member</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></div></co=
de></div><p style=3D"margin-bottom: 0px; font-size: 12px; line-height: norm=
al; font-family: Helvetica;"><br></p>
<p style=3D"margin-bottom: 0px; font-size: 12px; line-height: normal; font-=
family: Helvetica; min-height: 14px;"><br></p>
<p style=3D"margin-bottom: 0px; font-size: 12px; line-height: normal; font-=
family: Helvetica;">no this all looks good an well.</p>
<p style=3D"margin-bottom: 0px; font-size: 12px; line-height: normal; font-=
family: Helvetica;">BUT=E2=80=A6</p>
<p style=3D"margin-bottom: 0px; font-size: 12px; line-height: normal; font-=
family: Helvetica;">what about c++11 move semantics?</p>
<p style=3D"margin-bottom: 0px; font-size: 12px; line-height: normal; font-=
family: Helvetica; min-height: 14px;"><br></p>
<p style=3D"margin-bottom: 0px; font-size: 12px; line-height: normal; font-=
family: Helvetica;">well that would increase our definitions to the followi=
ng:</p>
<p style=3D"margin-bottom: 0px; font-size: 12px; line-height: normal; font-=
family: Helvetica; min-height: 14px;"><br></p>
<div class=3D"prettyprint" style=3D"background-color: rgb(250, 250, 250); b=
order: 1px solid rgb(187, 187, 187); word-wrap: break-word;"><code class=3D=
"prettyprint"><div class=3D"subprettyprint"><span style=3D"color: #008;" cl=
ass=3D"styled-by-prettify">class</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"> T<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><span style=3D"color: #008;" class=3D"styled-by-prett=
ify">public</span><span style=3D"color: #660;" class=3D"styled-by-prettify"=
>:</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br>&nbs=
p;M getMember</span><span style=3D"color: #660;" class=3D"styled-by-prettif=
y">()</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </sp=
an><span style=3D"color: #008;" class=3D"styled-by-prettify">const</span><s=
pan style=3D"color: #660;" class=3D"styled-by-prettify">;</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"><br>&nbsp;</span><span style=
=3D"color: #008;" class=3D"styled-by-prettify">void</span><span style=3D"co=
lor: #000;" class=3D"styled-by-prettify"> setMember</span><span style=3D"co=
lor: #660;" class=3D"styled-by-prettify">(</span><span style=3D"color: #000=
;" class=3D"styled-by-prettify">M </span><span style=3D"color: #008;" class=
=3D"styled-by-prettify">const</span><span style=3D"color: #660;" class=3D"s=
tyled-by-prettify">&amp;</span><span style=3D"color: #000;" class=3D"styled=
-by-prettify"> value</span><span style=3D"color: #660;" class=3D"styled-by-=
prettify">);</span><span style=3D"color: #000;" class=3D"styled-by-prettify=
"><br>&nbsp;</span><span style=3D"color: #008;" class=3D"styled-by-prettify=
">void</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> set=
Member</span><span style=3D"color: #660;" class=3D"styled-by-prettify">(</s=
pan><span style=3D"color: #000;" class=3D"styled-by-prettify">M</span><span=
 style=3D"color: #660;" class=3D"styled-by-prettify">&amp;&amp;</span><span=
 style=3D"color: #000;" class=3D"styled-by-prettify"> value</span><span sty=
le=3D"color: #660;" class=3D"styled-by-prettify">);</span><span style=3D"co=
lor: #000;" class=3D"styled-by-prettify"><br><br>&nbsp;</span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">=E2=80=A6</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"> other stuff </span><span st=
yle=3D"color: #660;" class=3D"styled-by-prettify">=E2=80=A6</span><span sty=
le=3D"color: #000;" class=3D"styled-by-prettify"><br></span><span style=3D"=
color: #008;" class=3D"styled-by-prettify">private</span><span style=3D"col=
or: #660;" class=3D"styled-by-prettify">:</span><span style=3D"color: #000;=
" class=3D"styled-by-prettify"><br>&nbsp;M member</span><span style=3D"colo=
r: #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></div></code></div><p style=3D"margin-botto=
m: 0px; font-size: 12px; line-height: normal; font-family: Helvetica;"><br>=
</p>
<p style=3D"margin-bottom: 0px; font-size: 12px; line-height: normal; font-=
family: Helvetica; min-height: 14px;"><br></p>
<p style=3D"margin-bottom: 0px; font-size: 12px; line-height: normal; font-=
family: Helvetica;">=E2=80=9COk that looks perfectly fine=E2=80=9D I can he=
ar you saying.</p>
<p style=3D"margin-bottom: 0px; font-size: 12px; line-height: normal; font-=
family: Helvetica; min-height: 14px;"><br></p>
<p style=3D"margin-bottom: 0px; font-size: 12px; line-height: normal; font-=
family: Helvetica;">Well that is ok for this simple trivial class.</p>
<p style=3D"margin-bottom: 0px; font-size: 12px; line-height: normal; font-=
family: Helvetica;">But what happens when things become a little less simpl=
e?</p>
<p style=3D"margin-bottom: 0px; font-size: 12px; line-height: normal; font-=
family: Helvetica;">Or another great standard feature s introduced? Maybe t=
he current best practises change and we need to now trawl through all of ou=
r code to add =E2=80=9Cnoexcept=E2=80=9D everywhere, or a new =E2=80=9Csupe=
r universal reference=E2=80=9D.</p>
<p style=3D"margin-bottom: 0px; font-size: 12px; line-height: normal; font-=
family: Helvetica;">Or even worse, you make a typo in your code and end up =
chasing your tail with spurious error messages from the compiler? (Which I =
have done on many occasions)</p>
<p style=3D"margin-bottom: 0px; font-size: 12px; line-height: normal; font-=
family: Helvetica;">Not to mention the extra (technically unneeded) definit=
ion in the cpp files.</p>
<p style=3D"margin-bottom: 0px; font-size: 12px; line-height: normal; font-=
family: Helvetica; min-height: 14px;"><br></p>
<p style=3D"margin-bottom: 0px; font-size: 12px; line-height: normal; font-=
family: Helvetica;">My problem with this is when you have a dozen or so of =
these, and their implementations are fairly trivial. Then why can this work=
 not be done by the compiler?</p>
<p style=3D"margin-bottom: 0px; font-size: 12px; line-height: normal; font-=
family: Helvetica; min-height: 14px;"><br></p>
<p style=3D"margin-bottom: 0px; font-size: 12px; line-height: normal; font-=
family: Helvetica;">What I have currently is a =E2=80=9CPre-Compiler=E2=80=
=9D process that creates these on the fly for me. This I think makes it muc=
h more simpler to create classes like this and also helps to reduce my code=
 bloat. Also I would argue that my new definition is more understandable an=
d direct about the intentions of the data it contains.</p>
<p style=3D"margin-bottom: 0px; font-size: 12px; line-height: normal; font-=
family: Helvetica; min-height: 14px;"><br></p>
<p style=3D"margin-bottom: 0px; font-size: 12px; line-height: normal; font-=
family: Helvetica;">Here is what my code currently shows.</p>
<p style=3D"margin-bottom: 0px; font-size: 12px; line-height: normal; font-=
family: Helvetica; min-height: 14px;"><br></p>
<div class=3D"prettyprint" style=3D"background-color: rgb(250, 250, 250); b=
order: 1px solid rgb(187, 187, 187); word-wrap: break-word;"><code class=3D=
"prettyprint"><div class=3D"subprettyprint"><span style=3D"color: #008;" cl=
ass=3D"styled-by-prettify">class</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"> T<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><span style=3D"color: #008;" class=3D"styled-by-prett=
ify">public</span><span style=3D"color: #660;" class=3D"styled-by-prettify"=
>:</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br>&nbs=
p;</span><span style=3D"color: #660;" class=3D"styled-by-prettify">=E2=80=
=A6</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> other =
stuff </span><span style=3D"color: #660;" class=3D"styled-by-prettify">=E2=
=80=A6</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br>=
</span><span style=3D"color: #008;" class=3D"styled-by-prettify">private</s=
pan><span style=3D"color: #660;" class=3D"styled-by-prettify">:</span><span=
 style=3D"color: #000;" class=3D"styled-by-prettify"><br>&nbsp;</span><span=
 style=3D"color: #660;" class=3D"styled-by-prettify">[[</span><span style=
=3D"color: #008;" class=3D"styled-by-prettify">public</span><span style=3D"=
color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #0=
08;" class=3D"styled-by-prettify">get</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">private</span><span style=3D"color: #000;" class=3D"styled-by-pret=
tify"> </span><span style=3D"color: #008;" class=3D"styled-by-prettify">set=
</span><span style=3D"color: #660;" class=3D"styled-by-prettify">]]</span><=
span style=3D"color: #000;" class=3D"styled-by-prettify"> M member</span><s=
pan 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: #660;" class=3D"styled-by-prettify">}</span></div></code></div><p styl=
e=3D"margin-bottom: 0px; font-size: 12px; line-height: normal; font-family:=
 Helvetica;"><br></p>
<p style=3D"margin-bottom: 0px; font-size: 12px; line-height: normal; font-=
family: Helvetica; min-height: 14px;"><br></p>
<p style=3D"margin-bottom: 0px; font-size: 12px; line-height: normal; font-=
family: Helvetica;">Now just think also of what the cpp file might now cont=
ain=E2=80=A6</p>
<p style=3D"margin-bottom: 0px; font-size: 12px; line-height: normal; font-=
family: Helvetica;">Only my "<b>other stuff"</b>. That's it. Just the impor=
tant details that are needed for the class.</p>
<p style=3D"margin-bottom: 0px; font-size: 12px; line-height: normal; font-=
family: Helvetica;"><br></p><p style=3D"margin-bottom: 0px; font-size: 12px=
; line-height: normal; font-family: Helvetica;">Now how clean and clear is =
that?</p>
<p style=3D"margin-bottom: 0px; font-size: 12px; line-height: normal; font-=
family: Helvetica; min-height: 14px;"><br></p>
<p style=3D"margin-bottom: 0px; font-size: 12px; line-height: normal; font-=
family: Helvetica;">with this new attribute I can define the following:</p>
<p style=3D"margin-bottom: 0px; font-size: 12px; line-height: normal; font-=
family: Helvetica; min-height: 14px;"><br></p>
<p style=3D"margin-bottom: 0px; font-size: 12px; line-height: normal; font-=
family: Helvetica;">[[public get]] or [[get]] or [[public get(default)]] or=
 [[get(default)]] -&gt; compiler should generate a default public getter fo=
r the data member.</p>
<p style=3D"margin-bottom: 0px; font-size: 12px; line-height: normal; font-=
family: Helvetica;">[[private set]] or [[private set(default)]] -&gt; compi=
ler generates a default trivial private setter.</p>
<p style=3D"margin-bottom: 0px; font-size: 12px; line-height: normal; font-=
family: Helvetica;">[[public set]] or [[public set(default)]] or [[set]] -&=
gt; compiler generates a default trivial prublic setter.</p>
<p style=3D"margin-bottom: 0px; font-size: 12px; line-height: normal; font-=
family: Helvetica;">[[public get(delete)]] or [[get(delete)]] -&gt; compile=
r does not create a getter (same as not defining the attribute at all but m=
ore direct about usage to an implementer).</p>
<p style=3D"margin-bottom: 0px; font-size: 12px; line-height: normal; font-=
family: Helvetica;">[[public set(delete)]] or [[set(delete)]] -&gt; compile=
r does not create a setter.</p>
<p style=3D"margin-bottom: 0px; font-size: 12px; line-height: normal; font-=
family: Helvetica;">[[get(randomGetterFunc)]] -&gt; compiler names the auto=
 generated function as required by the definition.</p><p style=3D"margin-bo=
ttom: 0px; font-size: 12px; line-height: normal; font-family: Helvetica;"><=
br></p>
<p style=3D"margin-bottom: 0px; font-size: 12px; line-height: normal; font-=
family: Helvetica;">To define both they only need to be separated by a comm=
a. This attribute should only ever contain a single get and set definition.=
</p>
<p style=3D"margin-bottom: 0px; font-size: 12px; line-height: normal; font-=
family: Helvetica; min-height: 14px;"><br></p>
<p style=3D"margin-bottom: 0px; font-size: 12px; line-height: normal; font-=
family: Helvetica;">I guess the easiest way to describe it is?</p>
<p style=3D"margin-bottom: 0px; font-size: 12px; line-height: normal; font-=
family: Helvetica; min-height: 14px;"><br></p>
<p style=3D"margin-bottom: 0px; font-size: 12px; line-height: normal; font-=
family: Helvetica;">[[{public<b>[=3Ddefault]</b>|private|protected} {get|se=
t}{(default|deleted|functionName)}{, ...}]]</p>
<p style=3D"margin-bottom: 0px; font-size: 12px; line-height: normal; font-=
family: Helvetica; min-height: 14px;"><br></p>
<p style=3D"margin-bottom: 0px; font-size: 12px; line-height: normal; font-=
family: Helvetica;">This is also much easier when writing template classes,=
 as the compiler already knows all the types and their abilities when stamp=
ing out specific versions.</p>
<p style=3D"margin-bottom: 0px; font-size: 12px; line-height: normal; font-=
family: Helvetica;">All in all using our simple =E2=80=9CPre-Compiler=E2=80=
=9D process I have reduced the code base I work on by 25%. Less Typing also=
 means I get an awful lot less bugs and more time to drool over the up and =
coming features of the c++ language (and in some cases learn how to use the=
m totally wrong).</p>
<p style=3D"margin-bottom: 0px; font-size: 12px; line-height: normal; font-=
family: Helvetica; min-height: 14px;"><br></p>
<p style=3D"margin-bottom: 0px; font-size: 12px; line-height: normal; font-=
family: Helvetica;">This also works well with our "inheritance aliasing". W=
hich is a whole other ball of wax and is already mentioned in another post =
on here.</p><p style=3D"margin-bottom: 0px; font-size: 12px; line-height: n=
ormal; font-family: Helvetica;"><br></p><p style=3D"margin-bottom: 0px; fon=
t-size: 12px; line-height: normal; font-family: Helvetica;">I hope this all=
 makes sense and wonder why peoples opinions are about this.</p><p style=3D=
"margin-bottom: 0px; font-size: 12px; line-height: normal; font-family: Hel=
vetica;"><br></p><p style=3D"margin-bottom: 0px; font-size: 12px; line-heig=
ht: normal; font-family: Helvetica;">IzzyCoding</p><p style=3D"margin-botto=
m: 0px; font-size: 12px; line-height: normal; font-family: Helvetica;">"Cod=
ing nothing is faster than coding something"</p>
<p style=3D"margin-bottom: 0px; font-size: 12px; line-height: normal; font-=
family: Helvetica; min-height: 14px;"><br></p></div>

<p></p>

-- <br />
<br />
--- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals&quot; 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_143_384466175.1417173108090--
------=_Part_142_1673212520.1417173108090--

.


Author: sasho648 <sasho648@mail.bg>
Date: Fri, 28 Nov 2014 12:39:40 -0800 (PST)
Raw View
------=_Part_737_722339982.1417207180340
Content-Type: multipart/alternative;
 boundary="----=_Part_738_643020983.1417207180340"

------=_Part_738_643020983.1417207180340
Content-Type: text/plain; charset=UTF-8

I believe the use of getters & setters is that someday you will want to
get/set the variable targeted different way. Using 'default' getters and
setters is useless - why don't you just impose the actual data by making
them public, the effect will be the same - think about 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_738_643020983.1417207180340
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr">I believe the use of getters &amp; setters is that someday=
 you will want to get/set the variable targeted different way. Using 'defau=
lt' getters and setters is useless - why don't you just impose the actual d=
ata by making them public, the effect will be the same - think about it.</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&quot; 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_738_643020983.1417207180340--
------=_Part_737_722339982.1417207180340--

.


Author: Izzy Coding <matthew.i.greenwood@gmail.com>
Date: Fri, 28 Nov 2014 15:58:55 -0800 (PST)
Raw View
------=_Part_7211_439635831.1417219135956
Content-Type: text/plain; charset=UTF-8

Where I work we have a coding rule we have to follow where no members can be directly used by anything that is not an instanciation of the class itself (or in some cases friend classes).
That said most of our members that we have require private setters and only public getters. This is because a lot of our classes are data containers and not just POD classes.

I still think some form of compiler generated functions would be helpful as the compiler knows more that we do. Also this would reduce the amount of code we write. Less code = less bugs (at least in theory)

--

---
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_7211_439635831.1417219135956--

.


Author: Bjorn Reese <breese@mail1.stofanet.dk>
Date: Sat, 29 Nov 2014 11:46:48 +0100
Raw View
On 11/28/2014 12:11 PM, Matthew Greenwood wrote:

> What I am talking about here is what I like to call autoGetSetter=E2=80=
=99s. The
> idea was inspired by the auto getter and setters in  dot Net.

This has been discussed several times:

https://groups.google.com/a/isocpp.org/forum/#!topic/std-proposals/n0QcD_K5=
dBY
https://groups.google.com/a/isocpp.org/forum/#!topic/std-proposals/HMyJqb3U=
Iq0
http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2014/n4147.pdf

--=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/.

.


Author: Izzy Coding <matthew.i.greenwood@gmail.com>
Date: Sun, 30 Nov 2014 02:34:20 -0800 (PST)
Raw View
------=_Part_579_2144029807.1417343660890
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

I think this may be getting viewed incorrectly.
I am not trying to create properties. Although with a small extension this =
could be possible.
I am merely trying to introduce some simplicity into the language.
This is more about reducing the requirement of writing code that the compil=
er could generate automatically. Thus reducing the possibility of bugs. In =
most cases it is only when we need two different access privileges for sett=
ing and getting values. Otherwise a developer can just use public or privat=
e member variable. In which case these attributes are irrelevant.

Also this is more about the auto created functions where we need to control=
 the access to the members.
A lot of our classes have members that are only privately settable. This me=
ans I have to define getter and setter functions. Also we do not believe th=
at anything other than the owning class should have direct access to the me=
mbers. Therefore we sometimes have protected setters to allow friend classe=
s making changes rather than allowing them direct access to the members. Th=
is is the main reason for allowing the default defended getter and setter w=
hich would remove the need for me to write two (if not more) trivial functi=
ons to cater for this.=20

In order to implement properties I would suggest an addition to the attribu=
te [[property(nameToUse), ...]] which would then define a link of nameToUse=
 to the relevant getter and/or setter for the assignment operations require=
d.

In my opinion this is more a shorthand convenience rather than to be a feat=
ure like properties. Also by using attributes it does not impact any existi=
ng language features and is merely a useful extension for the language.

--=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_579_2144029807.1417343660890--

.


Author: Izzy Coding <matthew.i.greenwood@gmail.com>
Date: Mon, 8 Dec 2014 01:27:25 -0800 (PST)
Raw View
------=_Part_841_147555059.1418030845752
Content-Type: multipart/alternative;
 boundary="----=_Part_842_1761747975.1418030845752"

------=_Part_842_1761747975.1418030845752
Content-Type: text/plain; charset=UTF-8

Hi,

Just wondering if there are any concerns or other comments for this idea?

That is for the idea of compiler generated functions (getter, setter) for
private member variables.
Not anything to do with "properties" (at least for now).

Regards,

--

---
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_842_1761747975.1418030845752
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr">Hi,<br><br>Just wondering if there are any concerns or oth=
er comments for this idea?<br><br>That is for the idea of compiler generate=
d functions (getter, setter) for private member variables.<br>Not anything =
to do with "properties" (at least for now).<br><br>Regards,<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&quot; 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_842_1761747975.1418030845752--
------=_Part_841_147555059.1418030845752--

.


Author: Sean Middleditch <sean.middleditch@gmail.com>
Date: Tue, 9 Dec 2014 16:25:38 -0800 (PST)
Raw View
------=_Part_4355_273264281.1418171138475
Content-Type: multipart/alternative;
 boundary="----=_Part_4356_1432733481.1418171138475"

------=_Part_4356_1432733481.1418171138475
Content-Type: text/plain; charset=UTF-8

I don't think this will get any positive support from the committee. It's a
fairly large language change that solves only one, single problem; there
are other ways to solve this (introspection + code synthesis) that would
solve this and many other problems. Language changes need to be general and
solve many problems, not specific to just one (otherwise the benefit/cost
ratio is far too low).

This feature as you describe is also too dependent on conventions outside
control of the standard, mostly around naming. Would the auto-generated
getter for `m_foo` be named m_foo_() or getm_foo() or get_m_foo() or
get_foo() or a Get* variation ? Will it handle all those different naming
conventions for member variables that exist like _foo, m_foo, mFoo, foo_,
s_foo, hungarian notations, different case, etc.?

I see no way to do this that will be generic to all codebases. I don't
think it's even possible to use it in the standard library since the member
variables there often need macro-resistant reserved names like _M_foo. As a
rule of thumb, if you can't use the feature in the standard library then
it's probably a good example of a feature that won't work well for C++.

On Monday, December 8, 2014 1:27:25 AM UTC-8, Izzy Coding wrote:
>
> Hi,
>
> Just wondering if there are any concerns or other comments for this idea?
>
> That is for the idea of compiler generated functions (getter, setter) for
> private member variables.
> Not anything to do with "properties" (at least for now).
>
> Regards,
>

--

---
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_4356_1432733481.1418171138475
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr">I don't think this will get any positive support from the =
committee. It's a fairly large language change that solves only one, single=
 problem; there are other ways to solve this (introspection + code synthesi=
s) that would solve this and many other problems. Language changes need to =
be general and solve many problems, not specific to just one (otherwise the=
 benefit/cost ratio is far too low).<div><br></div><div>This feature as you=
 describe is also too dependent on conventions outside control of the stand=
ard, mostly around naming. Would the auto-generated getter for `m_foo` be n=
amed m_foo_() or getm_foo() or get_m_foo() or get_foo() or a Get* variation=
 ? Will it handle all those different naming conventions for member variabl=
es that exist like _foo, m_foo, mFoo, foo_, s_foo, hungarian notations, dif=
ferent case, etc.?</div><div><br></div><div>I see no way to do this that wi=
ll be generic to all codebases. I don't think it's even possible to use it =
in the standard library since the member variables there often need macro-r=
esistant reserved names like _M_foo. As a rule of thumb, if you can't use t=
he feature in the standard library then it's probably a good example of a f=
eature that won't work well for C++.</div><div><br></div><div><div>On Monda=
y, December 8, 2014 1:27:25 AM UTC-8, Izzy Coding wrote:<blockquote class=
=3D"gmail_quote" style=3D"margin: 0;margin-left: 0.8ex;border-left: 1px #cc=
c solid;padding-left: 1ex;"><div dir=3D"ltr">Hi,<br><br>Just wondering if t=
here are any concerns or other comments for this idea?<br><br>That is for t=
he idea of compiler generated functions (getter, setter) for private member=
 variables.<br>Not anything to do with "properties" (at least for now).<br>=
<br>Regards,<br></div></blockquote></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&quot; 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_4356_1432733481.1418171138475--
------=_Part_4355_273264281.1418171138475--

.


Author: Izzy Coding <matthew.i.greenwood@gmail.com>
Date: Wed, 10 Dec 2014 01:21:08 -0800 (PST)
Raw View
------=_Part_83_1987744816.1418203268760
Content-Type: multipart/alternative;
 boundary="----=_Part_84_290311954.1418203268760"

------=_Part_84_290311954.1418203268760
Content-Type: text/plain; charset=UTF-8

As I am new to all of this I might be a little naive. I dont see how this
is a large change language wise, can you expand on that statement?
As far as I am aware the atribute syntax is already available and only used
for a few small things like deprecated. All of the ones I know of are
compiler hints.
My idea is also a compiler hint to specify an addition to force compiler
generated code. With regards to the naming I thought I had mentioned that
in the original post.

and atribute like the following means we do not need to care about naming
conventions as it would be down to the programmer. By default the default
(auto named) version would just append "set_" in front of the variable
name. So nothing really fancy with that.

private:
    [[public get(hereIsMyVar), private set(giveNewVar)]] typename
irrelevantInternalVarName;

which the compiler would equate to the following:

public:
    typename hereIsMyVar() const
    {
        return irrelevantInternalVarName;
    }

private:
    void giveNewVar(const typename& newValue)
    {
        irrelevantInternalVarName = newValue;
    }

    void giveNewVar(typename&& newValue)
    {
        irrelevantInternalVarName = std::move(newValue);
    }

    typename irrelevantInternalVarName;

of course this is just an example. I am sure there are things I have not
thought of. My problem is I am not sure why. So please help me to
understand why this is. Just saying the committee would not be happy about
it as it is little gain for alot of language change. What is the large
language change? And in my opinion this has a huge gain. To me this is like
"auto". It is just a way to tell the compiler I want the simple accessor
functions without having to write them in full. This reduces maintenance
cost and also ensures correct implementation. Also I would guess that the
compiler would also know more about the generated code in order to optimize
it in a better way. The compiler is much cleverer than I am (at least in
theory).

Please help me to understand this.

--

---
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_84_290311954.1418203268760
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr">As I am new to all of this I might be a little naive. I do=
nt see how this is a large change language wise, can you expand on that sta=
tement?<br>As far as I am aware the atribute syntax is already available an=
d only used for a few small things like deprecated. All of the ones I know =
of are compiler hints.<br>My idea is also a compiler hint to specify an add=
ition to force compiler generated code. With regards to the naming I though=
t I had mentioned that in the original post.<br><br>and atribute like the f=
ollowing means we do not need to care about naming conventions as it would =
be down to the programmer. By default the default (auto named) version woul=
d just append "set_" in front of the variable name. So nothing really fancy=
 with that.<br><br><div class=3D"prettyprint" style=3D"background-color: rg=
b(250, 250, 250); border-color: rgb(187, 187, 187); border-style: solid; bo=
rder-width: 1px; word-wrap: break-word;"><code class=3D"prettyprint"><div c=
lass=3D"subprettyprint"><span style=3D"color: #008;" class=3D"styled-by-pre=
ttify">private</span><span style=3D"color: #660;" class=3D"styled-by-pretti=
fy">:</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br>&=
nbsp; &nbsp; </span><span style=3D"color: #660;" class=3D"styled-by-prettif=
y">[[</span><span style=3D"color: #008;" class=3D"styled-by-prettify">publi=
c</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><=
span style=3D"color: #008;" class=3D"styled-by-prettify">get</span><span st=
yle=3D"color: #660;" class=3D"styled-by-prettify">(</span><span style=3D"co=
lor: #000;" class=3D"styled-by-prettify">hereIsMyVar</span><span style=3D"c=
olor: #660;" class=3D"styled-by-prettify">),</span><span style=3D"color: #0=
00;" class=3D"styled-by-prettify"> </span><span style=3D"color: #008;" clas=
s=3D"styled-by-prettify">private</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"> </span><span style=3D"color: #008;" class=3D"style=
d-by-prettify">set</span><span style=3D"color: #660;" class=3D"styled-by-pr=
ettify">(</span><span style=3D"color: #000;" class=3D"styled-by-prettify">g=
iveNewVar</span><span style=3D"color: #660;" class=3D"styled-by-prettify">)=
]]</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span>=
<span style=3D"color: #008;" class=3D"styled-by-prettify">typename</span><s=
pan style=3D"color: #000;" class=3D"styled-by-prettify"> irrelevantInternal=
VarName</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>which the compiler would equate to the following:<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"subpret=
typrint"><span style=3D"color: #008;" class=3D"styled-by-prettify">public</=
span><span style=3D"color: #660;" class=3D"styled-by-prettify">:</span><spa=
n style=3D"color: #000;" class=3D"styled-by-prettify"><br>&nbsp; &nbsp; </s=
pan><span style=3D"color: #008;" class=3D"styled-by-prettify">typename</spa=
n><span style=3D"color: #000;" class=3D"styled-by-prettify"> hereIsMyVar</s=
pan><span style=3D"color: #660;" class=3D"styled-by-prettify">()</span><spa=
n 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"c=
olor: #000;" class=3D"styled-by-prettify"><br>&nbsp; &nbsp; </span><span st=
yle=3D"color: #660;" class=3D"styled-by-prettify">{</span><span style=3D"co=
lor: #000;" class=3D"styled-by-prettify"><br>&nbsp; &nbsp; &nbsp; &nbsp; </=
span><span style=3D"color: #008;" class=3D"styled-by-prettify">return</span=
><span style=3D"color: #000;" class=3D"styled-by-prettify"> irrelevantInter=
nalVarName</span><span style=3D"color: #660;" class=3D"styled-by-prettify">=
;</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br>&nbsp=
; &nbsp; </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;" class=3D"styled-by-prettify">private</spa=
n><span style=3D"color: #660;" class=3D"styled-by-prettify">:</span><span s=
tyle=3D"color: #000;" class=3D"styled-by-prettify"><br>&nbsp; &nbsp; </span=
><span style=3D"color: #008;" class=3D"styled-by-prettify">void</span><span=
 style=3D"color: #000;" class=3D"styled-by-prettify"> giveNewVar</span><spa=
n style=3D"color: #660;" class=3D"styled-by-prettify">(</span><span style=
=3D"color: #008;" class=3D"styled-by-prettify">const</span><span style=3D"c=
olor: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #00=
8;" class=3D"styled-by-prettify">typename</span><span style=3D"color: #660;=
" class=3D"styled-by-prettify">&amp;</span><span style=3D"color: #000;" cla=
ss=3D"styled-by-prettify"> newValue</span><span style=3D"color: #660;" clas=
s=3D"styled-by-prettify">)</span><span style=3D"color: #000;" class=3D"styl=
ed-by-prettify"><br>&nbsp; &nbsp; </span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">{</span><span style=3D"color: #000;" class=3D"style=
d-by-prettify"><br>&nbsp; &nbsp; &nbsp; &nbsp; irrelevantInternalVarName </=
span><span style=3D"color: #660;" class=3D"styled-by-prettify">=3D</span><s=
pan style=3D"color: #000;" class=3D"styled-by-prettify"> newValue</span><sp=
an style=3D"color: #660;" class=3D"styled-by-prettify">;</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"><br>&nbsp; &nbsp; </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>&nbsp; &nbsp; </span=
><span style=3D"color: #008;" class=3D"styled-by-prettify">void</span><span=
 style=3D"color: #000;" class=3D"styled-by-prettify"> giveNewVar</span><spa=
n style=3D"color: #660;" class=3D"styled-by-prettify">(</span><span style=
=3D"color: #008;" class=3D"styled-by-prettify">typename</span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">&amp;&amp;</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"> newValue</span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">)</span><span style=3D"color=
: #000;" class=3D"styled-by-prettify"><br>&nbsp; &nbsp; </span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">{</span><span style=3D"color=
: #000;" class=3D"styled-by-prettify"><br>&nbsp; &nbsp; &nbsp; &nbsp; irrel=
evantInternalVarName </span><span style=3D"color: #660;" class=3D"styled-by=
-prettify">=3D</span><span style=3D"color: #000;" class=3D"styled-by-pretti=
fy"> std</span><span style=3D"color: #660;" class=3D"styled-by-prettify">::=
</span><span style=3D"color: #000;" class=3D"styled-by-prettify">move</span=
><span style=3D"color: #660;" class=3D"styled-by-prettify">(</span><span st=
yle=3D"color: #000;" class=3D"styled-by-prettify">newValue</span><span styl=
e=3D"color: #660;" class=3D"styled-by-prettify">);</span><span style=3D"col=
or: #000;" class=3D"styled-by-prettify"><br>&nbsp; &nbsp; </span><span styl=
e=3D"color: #660;" class=3D"styled-by-prettify">}</span><span style=3D"colo=
r: #000;" class=3D"styled-by-prettify"><br><br>&nbsp; &nbsp; </span><span s=
tyle=3D"color: #008;" class=3D"styled-by-prettify">typename</span><span sty=
le=3D"color: #000;" class=3D"styled-by-prettify"> irrelevantInternalVarName=
</span><span style=3D"color: #660;" class=3D"styled-by-prettify">;</span><s=
pan style=3D"color: #000;" class=3D"styled-by-prettify"><br></span></div></=
code></div><br>of course this is just an example. I am sure there are thing=
s I have not thought of. My problem is I am not sure why. So please help me=
 to understand why this is. Just saying the committee would not be happy ab=
out it as it is little gain for alot of language change. What is the large =
language change? And in my opinion this has a huge gain. To me this is like=
 "auto". It is just a way to tell the compiler I want the simple accessor f=
unctions without having to write them in full. This reduces maintenance cos=
t and also ensures correct implementation. Also I would guess that the comp=
iler would also know more about the generated code in order to optimize it =
in a better way. The compiler is much cleverer than I am (at least in theor=
y).<br><br>Please help me to understand this.<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&quot; 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_84_290311954.1418203268760--
------=_Part_83_1987744816.1418203268760--

.


Author: Tony V E <tvaneerd@gmail.com>
Date: Wed, 10 Dec 2014 12:48:46 -0500
Raw View
--089e0158b86e7b27c80509e04588
Content-Type: text/plain; charset=UTF-8

On Wed, Dec 10, 2014 at 4:21 AM, Izzy Coding <matthew.i.greenwood@gmail.com>
wrote:

> As I am new to all of this I might be a little naive. I dont see how this
> is a large change language wise, can you expand on that statement?
> As far as I am aware the atribute syntax is already available and only
> used for a few small things like deprecated. All of the ones I know of are
> compiler hints.
> My idea is also a compiler hint to specify an addition to force compiler
> generated code. With regards to the naming I thought I had mentioned that
> in the original post.
>
>
Attributes should be ignorable by the compiler, and should not change the
semantics of the program.  That's why they are hints.  This would be a
non-ignorable attribute.
So the committee could say that is OK, but more likely, so other syntax
would be required.  OK, that _might_ not be a big deal. But does it require
a new keyword? New uses of an old keyword?...  It could become a big deal.
For example, you are changing how 'public/private/protected' is used.
Maybe we should allow those per-variable (like Java).  Does that
compliment, complicate, or conflict with your proposal?


> of course this is just an example. I am sure there are things I have not
> thought of. My problem is I am not sure why. So please help me to
> understand why this is.  Just saying the committee would not be happy about
> it as it is little gain for alot of language change. What is the large
> language change? And in my opinion this has a huge gain.
>
>
It is the "things I have not thought of" category.  Maybe currently no one
knows what they are.  But from experience, we can all guess that they
exist.  It is the same as with software - it takes twice as long as you
think, even when you take that rule of thumb into account.

One example - the delete syntax: Is the setter not generated, or is the
setter *deleted* - there are subtle differences.

    struct Base
    {
        void set_x(int);
    };

    struct Derived : Base
    {
        public set(delete) int x;
    };

    Derived d;
    d.set_x(17);  // does this call Base::set_x() ??? or not compile???

Maybe there is an easy answer for that.  Maybe there are other subtleties
not yet discovered.  The above was just the first that came to mind.

Almost every new feature in C++ is a big feature - it is the nature of the
language.  ie the language is complicated, so any changes are complicated.
(Somewhat like a large old code-base - you know any and every change is
dangerous...)

Tony

--

---
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/.

--089e0158b86e7b27c80509e04588
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><br><div class=3D"gmail_extra"><br><div class=3D"gmail_quo=
te">On Wed, Dec 10, 2014 at 4:21 AM, Izzy Coding <span dir=3D"ltr">&lt;<a h=
ref=3D"mailto:matthew.i.greenwood@gmail.com" target=3D"_blank">matthew.i.gr=
eenwood@gmail.com</a>&gt;</span> wrote:<br><blockquote class=3D"gmail_quote=
" style=3D"margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);=
padding-left:1ex"><div dir=3D"ltr">As I am new to all of this I might be a =
little naive. I dont see how this is a large change language wise, can you =
expand on that statement?<br>As far as I am aware the atribute syntax is al=
ready available and only used for a few small things like deprecated. All o=
f the ones I know of are compiler hints.<br>My idea is also a compiler hint=
 to specify an addition to force compiler generated code. With regards to t=
he naming I thought I had mentioned that in the original post.<br><br></div=
></blockquote><div><br></div><div>Attributes should be ignorable by the com=
piler, and should not change the semantics of the program.=C2=A0 That&#39;s=
 why they are hints.=C2=A0 This would be a non-ignorable attribute.<br>So t=
he committee could say that is OK, but more likely, so other syntax would b=
e required.=C2=A0 OK, that _might_ not be a big deal. But does it require a=
 new keyword? New uses of an old keyword?...=C2=A0 It could become a big de=
al.=C2=A0 For example, you are changing how &#39;public/private/protected&#=
39; is used.=C2=A0 Maybe we should allow those per-variable (like Java).=C2=
=A0 Does that compliment, complicate, or conflict with your proposal?<br>=
=C2=A0 <br></div><blockquote class=3D"gmail_quote" style=3D"margin:0px 0px =
0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div>of =
course this is just an example. I am sure there are things I have not thoug=
ht of. My problem is I am not sure why. So please help me to understand why=
 this is.=C2=A0 Just saying the committee would not be happy about it as it=
 is little=20
gain for alot of language change. What is the large language change? And
 in my opinion this has a huge gain.<br><br></div></blockquote><div>=C2=A0<=
/div><div>It is the &quot;things I have not thought of&quot; category.=C2=
=A0 Maybe currently no one knows what they are.=C2=A0 But from experience, =
we can all guess that they exist.=C2=A0 It is the same as with software - i=
t takes twice as long as you think, even when you take that rule of thumb i=
nto account.<br><br></div><div>One example - the delete syntax: Is the sett=
er not generated, or is the setter *deleted* - there are subtle differences=
..<br><br></div><div>=C2=A0=C2=A0=C2=A0 struct Base<br>=C2=A0=C2=A0=C2=A0 {<=
br>=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 void set_x(int);<br>=C2=A0=C2=
=A0=C2=A0 };<br><br></div><div>=C2=A0=C2=A0=C2=A0 struct Derived : Base<br>=
=C2=A0=C2=A0=C2=A0 {<br></div><div>=C2=A0 =C2=A0 =C2=A0 =C2=A0 public set(d=
elete) int x;<br>=C2=A0=C2=A0=C2=A0 };<br><br></div><div>=C2=A0=C2=A0=C2=A0=
 Derived d;<br>=C2=A0=C2=A0=C2=A0 d.set_x(17);=C2=A0 // does this call Base=
::set_x() ??? or not compile???<br><br></div>Maybe there is an easy answer =
for that.=C2=A0 Maybe there are other subtleties not yet discovered.=C2=A0 =
The above was just the first that came to mind.<br><br></div><div class=3D"=
gmail_quote">Almost every new feature in C++ is a big feature - it is the n=
ature of the language.=C2=A0 ie the language is complicated, so any changes=
 are complicated.=C2=A0 (Somewhat like a large old code-base - you know any=
 and every change is dangerous...)<br><br></div><div class=3D"gmail_quote">=
Tony<br></div><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&quot; 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 />

--089e0158b86e7b27c80509e04588--

.


Author: "Vicente J. Botet Escriba" <vicente.botet@wanadoo.fr>
Date: Wed, 10 Dec 2014 19:33:43 +0100
Raw View
Le 08/12/14 10:27, Izzy Coding a =C3=A9crit :
> Hi,
>
> Just wondering if there are any concerns or other comments for this idea?
>
> That is for the idea of compiler generated functions (getter, setter)=20
> for private member variables.
> Not anything to do with "properties" (at least for now).
>
If you are not looking for properties, but only with access rights, you=20
don't need to generate any function.

If the single need is to have read-only public access maybe something=20
like this could be enough.

class X {
public:
     read_only int i;
};

You would need to take in consideration the wording of any access to a=20
member data, and see what can be done when the data is read-only.
Even if this seems simple, as Tony said is not a simple task as the=20
language is complex.

Vicente

--=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/.

.


Author: Izzy Coding <matthew.i.greenwood@gmail.com>
Date: Wed, 10 Dec 2014 23:44:50 -0800 (PST)
Raw View
------=_Part_6779_817050541.1418283890747
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

@Tony: That is exactly what I was looking for. I have an idea based on your=
 comment but want to spend a while to get it right. Thanks.

@Vincente: The idea of of read_only keyword I don't think would fit in this=
 case. Mainly because my intent is to be able to specify the protection of =
the getter and setter functions. Also I would not want to completely irradi=
ate the possibility of using this as a foundation for implementing a proper=
ties style of member variable (a dynamic member value as I see it).

Will post update later with new keyword and structure. Just checking some b=
its of standard to try and ensure the best possible fit.

--=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_6779_817050541.1418283890747--

.


Author: Olaf van der Spek <olafvdspek@gmail.com>
Date: Fri, 12 Dec 2014 05:45:48 -0800 (PST)
Raw View
------=_Part_26_1722803900.1418391948655
Content-Type: multipart/alternative;
 boundary="----=_Part_27_643134799.1418391948656"

------=_Part_27_643134799.1418391948656
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable



On Wednesday, December 10, 2014 7:33:46 PM UTC+1, Vicente J. Botet Escriba=
=20
wrote:
>
> Le 08/12/14 10:27, Izzy Coding a =C3=A9crit :=20
> > Hi,=20
> >=20
> > Just wondering if there are any concerns or other comments for this=20
> idea?=20
> >=20
> > That is for the idea of compiler generated functions (getter, setter)=
=20
> > for private member variables.=20
> > Not anything to do with "properties" (at least for now).=20
> >=20
> If you are not looking for properties, but only with access rights, you=
=20
> don't need to generate any function.=20
>
> If the single need is to have read-only public access maybe something=20
> like this could be enough.=20
>
> class X {=20
> public:=20
>      read_only int i;=20
> };=20
>

Read_only is a misnomer as it's only read_only for public access right?
Would it allow write access to derived classes?
Perhaps something like
public private:=20
and public protected: ?

It'd require no new keywords and handles both scenarios.

--=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_27_643134799.1418391948656
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><br><br>On Wednesday, December 10, 2014 7:33:46 PM UTC+1, =
Vicente J. Botet Escriba wrote:<blockquote class=3D"gmail_quote" style=3D"m=
argin: 0;margin-left: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;"=
>Le 08/12/14 10:27, Izzy Coding a =C3=A9crit :
<br>&gt; Hi,
<br>&gt;
<br>&gt; Just wondering if there are any concerns or other comments for thi=
s idea?
<br>&gt;
<br>&gt; That is for the idea of compiler generated functions (getter, sett=
er)=20
<br>&gt; for private member variables.
<br>&gt; Not anything to do with "properties" (at least for now).
<br>&gt;
<br>If you are not looking for properties, but only with access rights, you=
=20
<br>don't need to generate any function.
<br>
<br>If the single need is to have read-only public access maybe something=
=20
<br>like this could be enough.
<br>
<br>class X {
<br>public:
<br>&nbsp; &nbsp; &nbsp;read_only int i;
<br>};
<br></blockquote><div><br></div><div>Read_only is a misnomer as it's only r=
ead_only for public access right?</div><div>Would it allow write access to =
derived classes?</div><div>Perhaps something like</div><div>public private:=
&nbsp;</div><div>and public protected: ?</div><div><br></div><div>It'd requ=
ire no new keywords and handles both scenarios.</div><div><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&quot; 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_27_643134799.1418391948656--
------=_Part_26_1722803900.1418391948655--

.


Author: Izzy Coding <matthew.i.greenwood@gmail.com>
Date: Fri, 12 Dec 2014 14:26:10 -0800 (PST)
Raw View
------=_Part_836_904123384.1418423170457
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

That is definitely true.
Read_only would be symantically incorrect.

I was toying with the following ideas:

1)
private:
    typename memberName =3D {initialiser} -> writer([accessorName][,accessT=
ype]), reader([accessorName][,accessType]);

So the writer keyword would default to an accessType of private.
And the reader keyword would default the accessType to public.
with naming convention for default accessorName of set{memberName}.

2)
public|protected|private:
    setter(memberName) accessorName(...) =3D default; // creates simple wri=
te function (setter(memberName) =3D void type definition
    getter(memberName) accessorName(...) =3D delete; // if either setter or=
 getter is defined then by default both will be implemented by compiler. Th=
is tells compiler to not create the getter
    getter(memberName) accessorName(customParameters); // the getter(member=
Name) =3D type of the member. This for could be used to provide custom acce=
ssor functions or accessor functions that require different type parameters=
 than that of the members type

For this one all accessors of a given type for a member must have the same =
accessorName. So all getters must use the same functionName, as must all se=
tters. However getters and setters do not have to be named the same, but ca=
n be if that is required for the implementation.

3)
void operator get<memberName[,accessorName]>(...) =3D default; // specifies=
 a get operator function for the member defined. default means simple compi=
ler generated functions.
delete means no simple compiler generated functions when providing another =
accessor.

General usage in my company is that when specifying a variable accessor the=
 member variable should only ever be directly accessed by the constructor, =
destructor and the reader and writer functions. This way a developer can al=
ways guarantee that any access to the member always has any required proces=
sing / validation done.

Personally I am leaning towards version 2 as it would fit in like a general=
 set of functions. Also it would allow for multiple getters and setters to =
be specified. The compiler would then be responsible for creating the defin=
ition as part of compiling the cpp logical unit.

--=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_836_904123384.1418423170457--

.


Author: "Vicente J. Botet Escriba" <vicente.botet@wanadoo.fr>
Date: Sat, 13 Dec 2014 14:13:39 +0100
Raw View
Le 11/12/14 08:44, Izzy Coding a =C3=A9crit :
> @Vincente: The idea of of read_only keyword I don't think would fit in th=
is case. Mainly because my intent is to be able to specify the protection o=
f the getter and setter functions. Also I would not want to completely irra=
diate the possibility of using this as a foundation for implementing a prop=
erties style of member variable (a dynamic member value as I see it).
>
>
I'm not attached to the read_only keyword. My concern is that we don't=20
need getters/setter to provide read-only access from outside the class.

I believed you were not locking for a properties proposal ;-)

Vicente

--=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/.

.


Author: sasho648 <sasho648@mail.bg>
Date: Sat, 13 Dec 2014 06:21:07 -0800 (PST)
Raw View
------=_Part_1354_214453414.1418480467255
Content-Type: multipart/alternative;
 boundary="----=_Part_1355_1583362717.1418480467255"

------=_Part_1355_1583362717.1418480467255
Content-Type: text/plain; charset=UTF-8

You can actually implement the behavior of the possible 'read_only' keyword
by using union inheritance or unnamed unions (or it should be possible but
the current ISO C++ standard won't allow us to do so). Here is what I mean:

inline namespace
{
    union A_members
    {
        A_members() {};

    protected:
        struct {int _a, _b, _c; };
    public:
        struct {const int a, b, c; };
    };
}


class A : public A_members //error unions can't be inherited
{

};


As a, b, c will be the public constant aliases of the private non-constant
_a, _b, _c variables. Using unnamed unions won't be possible too, because
they can't have any different than public members:

class A
{
    union //Generate compiler error, unnamed unions can have only public
members
    {
    private:
        struct {int _a, _b, _c; };
    public:
        struct {const int a, b, c; };
    };
};


So for now the only possible implementation of the above is using those
get/setters or named unions like this:

struct A
{
    A() = default;

    union Name
    {
        Name() {};

    private:
        struct {int _a, _b, _c; };
    public:
        struct {const int a, b, c; };

    friend class A;
    } a_members;

    void SomeMethod() { a_members._a = 9; }   //uses the 'private'
non-const version of 'a' in order to edit it
};

In which case you should use 'a_members' to access 'A' members which is
somehow stupid. Life example
<http://melpon.org/wandbox/permlink/iTgOWnEuWkHa3ip5>.

--

---
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_1355_1583362717.1418480467255
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr">You can actually implement the behavior of the possible 'r=
ead_only' keyword by using union inheritance or unnamed unions (or it shoul=
d be possible but the current ISO C++ standard won't allow us to do so). He=
re is what I mean:<br><br><div class=3D"prettyprint" style=3D"border: 1px s=
olid rgb(187, 187, 187); word-wrap: break-word; background-color: rgb(250, =
250, 250);"><code class=3D"prettyprint"><div class=3D"subprettyprint"><span=
 style=3D"color: #008;" class=3D"styled-by-prettify">inline</span><span sty=
le=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"col=
or: #008;" class=3D"styled-by-prettify">namespace</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>&nbsp; &nbsp; </span><span style=3D"color: #008=
;" class=3D"styled-by-prettify">union</span><span style=3D"color: #000;" cl=
ass=3D"styled-by-prettify"> A_members<br>&nbsp; &nbsp; </span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">{</span><span style=3D"color=
: #000;" class=3D"styled-by-prettify"><br>&nbsp; &nbsp; &nbsp; &nbsp; A_mem=
bers</span><span style=3D"color: #660;" class=3D"styled-by-prettify">()</sp=
an><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span =
style=3D"color: #660;" class=3D"styled-by-prettify">{};</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"><br>&nbsp; &nbsp; &nbsp; &nb=
sp; <br>&nbsp; &nbsp; </span><span style=3D"color: #008;" class=3D"styled-b=
y-prettify">protected</span><span style=3D"color: #660;" class=3D"styled-by=
-prettify">:</span><span style=3D"color: #000;" class=3D"styled-by-prettify=
"><br>&nbsp; &nbsp; &nbsp; &nbsp; </span><span style=3D"color: #008;" class=
=3D"styled-by-prettify">struct</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: #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><spa=
n 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;" class=3D"styled-by-prettify"> _c</span><span style=3D"color: #660;=
" class=3D"styled-by-prettify">;</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"> </span><span style=3D"color: #660;" class=3D"style=
d-by-prettify">};</span><span style=3D"color: #000;" class=3D"styled-by-pre=
ttify"><br>&nbsp; &nbsp; </span><span style=3D"color: #008;" class=3D"style=
d-by-prettify">public</span><span style=3D"color: #660;" class=3D"styled-by=
-prettify">:</span><span style=3D"color: #000;" class=3D"styled-by-prettify=
"><br>&nbsp; &nbsp; &nbsp; &nbsp; </span><span style=3D"color: #008;" class=
=3D"styled-by-prettify">struct</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: #008;" class=3D"styled-by-prettify=
">const</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </=
span><span style=3D"color: #008;" class=3D"styled-by-prettify">int</span><s=
pan style=3D"color: #000;" class=3D"styled-by-prettify"> a</span><span styl=
e=3D"color: #660;" class=3D"styled-by-prettify">,</span><span style=3D"colo=
r: #000;" class=3D"styled-by-prettify"> 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"styl=
ed-by-prettify">;</span><span style=3D"color: #000;" class=3D"styled-by-pre=
ttify"> </span><span style=3D"color: #660;" class=3D"styled-by-prettify">};=
</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br>&nbsp;=
 &nbsp; </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 st=
yle=3D"color: #000;" class=3D"styled-by-prettify"><br><br><br></span><span =
style=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"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">public</span><span style=3D"color: #000;" class=3D"=
styled-by-prettify"> A_members </span><span style=3D"color: #800;" class=3D=
"styled-by-prettify">//error unions can't be inherited </span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"><br></span><span style=3D"co=
lor: #660;" class=3D"styled-by-prettify">{</span><span style=3D"color: #000=
;" class=3D"styled-by-prettify"><br>&nbsp; &nbsp; <br></span><span style=3D=
"color: #660;" class=3D"styled-by-prettify">};</span></div></code></div><di=
v><br></div><div><br>As a, b, c will be the public constant aliases of the =
private non-constant _a, _b, _c variables. Using unnamed unions won't be po=
ssible too, because they can't have any different than public members:</div=
><div><br></div><div><div class=3D"prettyprint" style=3D"border: 1px solid =
rgb(187, 187, 187); word-wrap: break-word; background-color: rgb(250, 250, =
250);"><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<br></span><span style=3D"colo=
r: #660;" class=3D"styled-by-prettify">{</span><span style=3D"color: #000;"=
 class=3D"styled-by-prettify"><br>&nbsp; &nbsp; </span><span style=3D"color=
: #008;" class=3D"styled-by-prettify">union</span><span style=3D"color: #00=
0;" class=3D"styled-by-prettify"> </span><span style=3D"color: #800;" class=
=3D"styled-by-prettify">//Generate compiler error, unnamed unions can have =
only public members</span><span style=3D"color: #000;" class=3D"styled-by-p=
rettify"><br>&nbsp; &nbsp; </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>&nbsp; &nbsp; </span><span style=3D"color: #008;" class=3D"styl=
ed-by-prettify">private</span><span style=3D"color: #660;" class=3D"styled-=
by-prettify">:</span><span style=3D"color: #000;" class=3D"styled-by-pretti=
fy"><br>&nbsp; &nbsp; &nbsp; &nbsp; </span><span style=3D"color: #008;" cla=
ss=3D"styled-by-prettify">struct</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"> </span><span style=3D"color: #660;" class=3D"style=
d-by-prettify">{</span><span style=3D"color: #008;" class=3D"styled-by-pret=
tify">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"styled-by-prettify"> _b</span><span s=
tyle=3D"color: #660;" class=3D"styled-by-prettify">,</span><span style=3D"c=
olor: #000;" class=3D"styled-by-prettify"> _c</span><span style=3D"color: #=
660;" class=3D"styled-by-prettify">;</span><span style=3D"color: #000;" cla=
ss=3D"styled-by-prettify"> </span><span style=3D"color: #660;" class=3D"sty=
led-by-prettify">};</span><span style=3D"color: #000;" class=3D"styled-by-p=
rettify"><br>&nbsp; &nbsp; </span><span style=3D"color: #008;" class=3D"sty=
led-by-prettify">public</span><span style=3D"color: #660;" class=3D"styled-=
by-prettify">:</span><span style=3D"color: #000;" class=3D"styled-by-pretti=
fy"><br>&nbsp; &nbsp; &nbsp; &nbsp; </span><span style=3D"color: #008;" cla=
ss=3D"styled-by-prettify">struct</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"> </span><span style=3D"color: #660;" class=3D"style=
d-by-prettify">{</span><span style=3D"color: #008;" class=3D"styled-by-pret=
tify">const</span><span style=3D"color: #000;" class=3D"styled-by-prettify"=
> </span><span style=3D"color: #008;" class=3D"styled-by-prettify">int</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;" cla=
ss=3D"styled-by-prettify"> c</span><span style=3D"color: #660;" class=3D"st=
yled-by-prettify">;</span><span style=3D"color: #000;" class=3D"styled-by-p=
rettify"> </span><span style=3D"color: #660;" class=3D"styled-by-prettify">=
};</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br>&nbs=
p; &nbsp; </span><span style=3D"color: #660;" class=3D"styled-by-prettify">=
};</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br></sp=
an><span style=3D"color: #660;" class=3D"styled-by-prettify">};</span></div=
></code></div><div><br></div><br>So for now the only possible implementatio=
n of the above is using those get/setters or named unions like this:<br><br=
><div class=3D"prettyprint" style=3D"border: 1px solid rgb(187, 187, 187); =
word-wrap: break-word; background-color: rgb(250, 250, 250);"><code class=
=3D"prettyprint"><div class=3D"subprettyprint"><span style=3D"color: #008;"=
 class=3D"styled-by-prettify">struct</span><span style=3D"color: #000;" cla=
ss=3D"styled-by-prettify"> A<br></span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">{</span><span style=3D"color: #000;" class=3D"style=
d-by-prettify"><br>&nbsp; &nbsp; A</span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">()</span><span style=3D"color: #000;" class=3D"styl=
ed-by-prettify"> </span><span style=3D"color: #660;" class=3D"styled-by-pre=
ttify">=3D</span><span style=3D"color: #000;" class=3D"styled-by-prettify">=
 </span><span style=3D"color: #008;" class=3D"styled-by-prettify">default</=
span><span style=3D"color: #660;" class=3D"styled-by-prettify">;</span><spa=
n style=3D"color: #000;" class=3D"styled-by-prettify"><br>&nbsp; &nbsp; <br=
>&nbsp; &nbsp; </span><span style=3D"color: #008;" class=3D"styled-by-prett=
ify">union</span><span style=3D"color: #000;" class=3D"styled-by-prettify">=
 </span><span style=3D"color: #606;" class=3D"styled-by-prettify">Name</spa=
n><span style=3D"color: #000;" class=3D"styled-by-prettify"><br>&nbsp; &nbs=
p; </span><span style=3D"color: #660;" class=3D"styled-by-prettify">{</span=
><span style=3D"color: #000;" class=3D"styled-by-prettify"><br>&nbsp; &nbsp=
; &nbsp; &nbsp; </span><span style=3D"color: #606;" class=3D"styled-by-pret=
tify">Name</span><span style=3D"color: #660;" class=3D"styled-by-prettify">=
()</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span>=
<span style=3D"color: #660;" class=3D"styled-by-prettify">{};</span><span s=
tyle=3D"color: #000;" class=3D"styled-by-prettify"><br>&nbsp; &nbsp; &nbsp;=
 &nbsp; <br>&nbsp; &nbsp; </span><span style=3D"color: #008;" class=3D"styl=
ed-by-prettify">private</span><span style=3D"color: #660;" class=3D"styled-=
by-prettify">:</span><span style=3D"color: #000;" class=3D"styled-by-pretti=
fy"><br>&nbsp; &nbsp; &nbsp; &nbsp; </span><span style=3D"color: #008;" cla=
ss=3D"styled-by-prettify">struct</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"> </span><span style=3D"color: #660;" class=3D"style=
d-by-prettify">{</span><span style=3D"color: #008;" class=3D"styled-by-pret=
tify">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"styled-by-prettify"> _b</span><span s=
tyle=3D"color: #660;" class=3D"styled-by-prettify">,</span><span style=3D"c=
olor: #000;" class=3D"styled-by-prettify"> _c</span><span style=3D"color: #=
660;" class=3D"styled-by-prettify">;</span><span style=3D"color: #000;" cla=
ss=3D"styled-by-prettify"> </span><span style=3D"color: #660;" class=3D"sty=
led-by-prettify">};</span><span style=3D"color: #000;" class=3D"styled-by-p=
rettify"><br>&nbsp; &nbsp; </span><span style=3D"color: #008;" class=3D"sty=
led-by-prettify">public</span><span style=3D"color: #660;" class=3D"styled-=
by-prettify">:</span><span style=3D"color: #000;" class=3D"styled-by-pretti=
fy"><br>&nbsp; &nbsp; &nbsp; &nbsp; </span><span style=3D"color: #008;" cla=
ss=3D"styled-by-prettify">struct</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"> </span><span style=3D"color: #660;" class=3D"style=
d-by-prettify">{</span><span style=3D"color: #008;" class=3D"styled-by-pret=
tify">const</span><span style=3D"color: #000;" class=3D"styled-by-prettify"=
> </span><span style=3D"color: #008;" class=3D"styled-by-prettify">int</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;" cla=
ss=3D"styled-by-prettify"> c</span><span style=3D"color: #660;" class=3D"st=
yled-by-prettify">;</span><span style=3D"color: #000;" class=3D"styled-by-p=
rettify"> </span><span style=3D"color: #660;" class=3D"styled-by-prettify">=
};</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br>&nbs=
p; &nbsp; &nbsp; &nbsp; <br>&nbsp; &nbsp; </span><span style=3D"color: #008=
;" class=3D"styled-by-prettify">friend</span><span style=3D"color: #000;" c=
lass=3D"styled-by-prettify"> </span><span style=3D"color: #008;" class=3D"s=
tyled-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-pret=
tify">;</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br=
>&nbsp; &nbsp; </span><span style=3D"color: #660;" class=3D"styled-by-prett=
ify">}</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> a_m=
embers</span><span style=3D"color: #660;" class=3D"styled-by-prettify">;</s=
pan><span style=3D"color: #000;" class=3D"styled-by-prettify"><br>&nbsp; &n=
bsp; <br>&nbsp; &nbsp; </span><span style=3D"color: #008;" class=3D"styled-=
by-prettify">void</span><span style=3D"color: #000;" class=3D"styled-by-pre=
ttify"> </span><span style=3D"color: #606;" class=3D"styled-by-prettify">So=
meMethod</span><span style=3D"color: #660;" class=3D"styled-by-prettify">()=
</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><s=
pan style=3D"color: #660;" class=3D"styled-by-prettify">{</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"> a_members</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">=3D</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"> </span><span style=3D"color: #066;" class=3D"style=
d-by-prettify">9</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: #660;" class=3D"styled-by-prettify">}</span><spa=
n style=3D"color: #000;" class=3D"styled-by-prettify"> &nbsp; </span><span =
style=3D"color: #800;" class=3D"styled-by-prettify">//uses the 'private' no=
n-const version of 'a' in order to edit it &nbsp; &nbsp; </span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"><br></span><span style=3D"co=
lor: #660;" class=3D"styled-by-prettify">};</span></div></code></div><div><=
br></div></div><div>In which case you should use '<span style=3D"color: rgb=
(0, 0, 0); font-family: monospace; background-color: rgb(250, 250, 250);">a=
_members</span>' to access 'A' members which is somehow stupid. Life <a hre=
f=3D"http://melpon.org/wandbox/permlink/iTgOWnEuWkHa3ip5">example</a>.</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&quot; 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_1355_1583362717.1418480467255--
------=_Part_1354_214453414.1418480467255--

.


Author: sasho648 <sasho648@mail.bg>
Date: Sat, 13 Dec 2014 06:25:04 -0800 (PST)
Raw View
------=_Part_170_865300249.1418480704868
Content-Type: multipart/alternative;
 boundary="----=_Part_171_342027459.1418480704868"

------=_Part_171_342027459.1418480704868
Content-Type: text/plain; charset=UTF-8

So I believe a better idea is to enable unions inheritance and the
possibility for unnamed unions to have members with access level different
than 'public'.

--

---
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_171_342027459.1418480704868
Content-Type: text/html; charset=UTF-8

<div dir="ltr">So I believe a better idea is to enable unions inheritance and the possibility for unnamed unions to have members with access level different than 'public'.</div>

<p></p>

-- <br />
<br />
--- <br />
You received this message because you are subscribed to the Google Groups &quot;ISO C++ Standard - Future Proposals&quot; 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_171_342027459.1418480704868--
------=_Part_170_865300249.1418480704868--

.


Author: Izzy Coding <matthew.i.greenwood@gmail.com>
Date: Sat, 13 Dec 2014 23:13:49 -0800 (PST)
Raw View
------=_Part_19_1256213198.1418541229345
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

@sasho648: First of all, read_only is not the symantically meaning we are t=
rying to get at here. What this is for is a way to define member accessor f=
unctions that the compiler would create for us. Secondly, my understanding =
of unions is that you can only use one of its members at any given time. So=
 how would your idea work? Surely there would need to be a mapping between =
a and _a, ...?

I am currently writing up idea 2 with full details. Will post soon to see w=
hat people think. I also have an idea on how to extend this and what that m=
eans to make this into properties (if anyone should want that behaviour)

--=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_19_1256213198.1418541229345--

.


Author: Izzy Coding <matthew.i.greenwood@gmail.com>
Date: Sat, 13 Dec 2014 23:26:28 -0800 (PST)
Raw View
------=_Part_1706_1680631461.1418541988608
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

@Vicente: although I am not actively looking to introduce properties. I don=
't want any proposal to limit the possibility of them in the future. That s=
aid read_only does not apply in this case I think. How would I know from ju=
st that if I wanted the following:

Public Read and Private Write
Protected Read and Protected Write
Public Read and Protected Write
Public Read and Public Write // is possible but most likely not going to be=
 done
Private Read and Private Write // also possible but most likely not going t=
o be done

The reason for accessor functions in most cases is for greater control over=
 member access. Also these don't have to be trivial functions. E.g. I could=
 want to validate input before assigning it to the member. Or check bounds =
of an array. Or this could allow for slightly differing functions based on =
their access. Maybe if I call setMember from my class it doesn't do validat=
ions, if I call as a protected / derived class I get partial validations, a=
nd if I call from anybody from outside my class it gets full validation. Th=
at way ensuring the best possible performance of my code. This would also m=
ake it easier to reason about what is going on for member variable usage.

--=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_1706_1680631461.1418541988608--

.


Author: "Vicente J. Botet Escriba" <vicente.botet@wanadoo.fr>
Date: Sun, 14 Dec 2014 09:54:24 +0100
Raw View
Le 14/12/14 08:26, Izzy Coding a =C3=A9crit :
> @Vicente: although I am not actively looking to introduce properties. I d=
on't want any proposal to limit the possibility of them in the future. That=
 said read_only does not apply in this case I think. How would I know from =
just that if I wanted the following:
>
> Public Read and Private Write
private:  read_only int i;
> Protected Read and Protected Write
protected: int i;
> Public Read and Protected Write
protected: read_only int i;
> Public Read and Public Write // is possible but most likely not going to =
be done
public: int i;
> Private Read and Private Write // also possible but most likely not going=
 to be done
private: int i;



Alternatively add a specific read-only declaration with the appropriated=20
access.

Public Read and Private Write

private: int i;
public: readonly i;

> Public Read and Protected Write
protected:  int i;
public: readonly i;

>
> The reason for accessor functions in most cases is for greater control ov=
er member access. Also these don't have to be trivial functions. E.g. I cou=
ld want to validate input before assigning it to the member. Or check bound=
s of an array. Or this could allow for slightly differing functions based o=
n their access. Maybe if I call setMember from my class it doesn't do valid=
ations, if I call as a protected / derived class I get partial validations,=
 and if I call from anybody from outside my class it gets full validation. =
That way ensuring the best possible performance of my code. This would also=
 make it easier to reason about what is going on for member variable usage.
>
If you want to add code on access this is a property. As it has been=20
discussed lengthly in this and other ML,  properties can be implemented=20
using just member functions.

Good luck,
Vicente

--=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/.

.


Author: sasho648 <sasho648@mail.bg>
Date: Sat, 13 Dec 2014 06:05:29 -0800 (PST)
Raw View
------=_Part_1383_592721016.1418479529387
Content-Type: multipart/alternative;
 boundary="----=_Part_1384_1832961126.1418479529388"

------=_Part_1384_1832961126.1418479529388
Content-Type: text/plain; charset=UTF-8

There could be a way to implement such behavior in which public members
will be only read-only from class users but still read/write enabled for
in-class member functions and friends by using unions inheritance (which
however is currently forbidden by ISO C++ and the other way implementing it
- using unnamed unions is useless in the case, because their members can
only be public). Here is what I mean:

inline namespace
{
    union A_members
    {
    protected:
        struct {int _a, _b, _c; }; // in-class members will use the
non-const names of the variables
    public:
        struct {const int a, b, c; }; // public request will use the const
names of the same variables
    };
}


class A : public A_members //Inherit members of 'class A ', currently
produces compiler error, as unions can't be inherited
{
};

Or by using unnamed unions which however can't have 'private' members so
they are useless for now too :

class A
{
   union //will produce error, unnamed unions can't have private members
   {
   private:
       struct {int _a, _b, _c; };
   public:
       struct {const int a, b, c; };
   };
}

For now the only option is using a named 'union' as a class member like
this:

struct A
{
    A() = default;

    union Name
    {
        Name() {};

    private:
        struct {int _a, _b, _c; };
    public:
        struct {const int a, b, c; };

    friend class A;
    } a_members;

    void SomeMethod() { a_members._a = 9; }   //uses the 'private'
non-const version of 'a' in order to edit it
};

And access 'A' members from 'a_members' which is somehow stupid but the
best solution yet, preventing the need to write getters and setters
manually.

Life example <http://melpon.org/wandbox/permlink/iTgOWnEuWkHa3ip5>.

--

---
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_1384_1832961126.1418479529388
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr">There could be a way to implement such behavior in which p=
ublic members will be only read-only from class users but still read/write =
enabled for in-class member functions and friends by using unions inheritan=
ce (which however is currently forbidden by ISO C++ and the other way imple=
menting it - using unnamed unions is useless in the case, because their mem=
bers can only be public). Here is what I mean:<br><br><div class=3D"prettyp=
rint" style=3D"border: 1px solid rgb(187, 187, 187); word-wrap: break-word;=
 background-color: rgb(250, 250, 250);"><code class=3D"prettyprint"><div cl=
ass=3D"subprettyprint"><span style=3D"color: #008;" class=3D"styled-by-pret=
tify">inline</span><span style=3D"color: #000;" class=3D"styled-by-prettify=
"> </span><span style=3D"color: #008;" class=3D"styled-by-prettify">namespa=
ce</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br></sp=
an><span style=3D"color: #660;" class=3D"styled-by-prettify">{</span><span =
style=3D"color: #000;" class=3D"styled-by-prettify"><br>&nbsp; &nbsp; </spa=
n><span style=3D"color: #008;" class=3D"styled-by-prettify">union</span><sp=
an style=3D"color: #000;" class=3D"styled-by-prettify"> A_members<br>&nbsp;=
 &nbsp; </span><span style=3D"color: #660;" class=3D"styled-by-prettify">{<=
/span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br>&nbsp; =
&nbsp; </span><span style=3D"color: #008;" class=3D"styled-by-prettify">pro=
tected</span><span style=3D"color: #660;" class=3D"styled-by-prettify">:</s=
pan><span style=3D"color: #000;" class=3D"styled-by-prettify"><br>&nbsp; &n=
bsp; &nbsp; &nbsp;&nbsp;</span><span style=3D"color: rgb(136, 0, 0); font-f=
amily: Arial, Helvetica, sans-serif; background-color: rgb(255, 255, 255);"=
>struct {</span><span class=3D"styled-by-prettify" style=3D"font-family: Ar=
ial, Helvetica, sans-serif; color: rgb(0, 0, 136);">int</span><span class=
=3D"styled-by-prettify" style=3D"font-family: Arial, Helvetica, sans-serif;=
 color: rgb(0, 0, 0);"> _a</span><span class=3D"styled-by-prettify" style=
=3D"font-family: Arial, Helvetica, sans-serif; color: rgb(102, 102, 0);">,<=
/span><span class=3D"styled-by-prettify" style=3D"font-family: Arial, Helve=
tica, sans-serif; color: rgb(0, 0, 0);"> _b</span><span class=3D"styled-by-=
prettify" style=3D"font-family: Arial, Helvetica, sans-serif; color: rgb(10=
2, 102, 0);">,</span><span class=3D"styled-by-prettify" style=3D"font-famil=
y: Arial, Helvetica, sans-serif; color: rgb(0, 0, 0);"> _c; }</span><span c=
lass=3D"styled-by-prettify" style=3D"font-family: Arial, Helvetica, sans-se=
rif; color: rgb(102, 102, 0);">;</span><span class=3D"styled-by-prettify" s=
tyle=3D"font-family: Arial, Helvetica, sans-serif; color: rgb(0, 0, 0);"> <=
/span><span class=3D"styled-by-prettify" style=3D"font-family: Arial, Helve=
tica, sans-serif; color: rgb(136, 0, 0);">// in-class members will use the =
non-const names of the variables</span></div><div class=3D"subprettyprint">=
<span style=3D"color: #000;" class=3D"styled-by-prettify">&nbsp; &nbsp; </s=
pan><span style=3D"color: #008;" class=3D"styled-by-prettify">public</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; &nbsp; &nbsp; &=
nbsp;&nbsp;</span><span style=3D"color: rgb(136, 0, 0); font-family: Arial,=
 Helvetica, sans-serif; background-color: rgb(255, 255, 255);">struct {</sp=
an><span class=3D"styled-by-prettify" style=3D"font-family: Arial, Helvetic=
a, sans-serif; color: rgb(0, 0, 136);">const</span><span class=3D"styled-by=
-prettify" style=3D"font-family: Arial, Helvetica, sans-serif; color: rgb(0=
, 0, 0);"> </span><span class=3D"styled-by-prettify" style=3D"font-family: =
Arial, Helvetica, sans-serif; color: rgb(0, 0, 136);">int</span><span class=
=3D"styled-by-prettify" style=3D"font-family: Arial, Helvetica, sans-serif;=
 color: rgb(0, 0, 0);"> a</span><span class=3D"styled-by-prettify" style=3D=
"font-family: Arial, Helvetica, sans-serif; color: rgb(102, 102, 0);">,</sp=
an><span class=3D"styled-by-prettify" style=3D"font-family: Arial, Helvetic=
a, sans-serif; color: rgb(0, 0, 0);"> b</span><span class=3D"styled-by-pret=
tify" style=3D"font-family: Arial, Helvetica, sans-serif; color: rgb(102, 1=
02, 0);">,</span><span class=3D"styled-by-prettify" style=3D"font-family: A=
rial, Helvetica, sans-serif; color: rgb(0, 0, 0);"> c; }</span><span class=
=3D"styled-by-prettify" style=3D"font-family: Arial, Helvetica, sans-serif;=
 color: rgb(102, 102, 0);">;</span><span class=3D"styled-by-prettify" style=
=3D"font-family: Arial, Helvetica, sans-serif; color: rgb(0, 0, 0);"> </spa=
n><span class=3D"styled-by-prettify" style=3D"font-family: Arial, Helvetica=
, sans-serif; color: rgb(136, 0, 0);">// public request will use the const =
names of the same </span><span style=3D"font-family: Arial, Helvetica, sans=
-serif; color: rgb(136, 0, 0);"><span class=3D"styled-by-prettify">variable=
s</span></span></div><div class=3D"subprettyprint"><span style=3D"color: #0=
00;" class=3D"styled-by-prettify">&nbsp; &nbsp; </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"style=
d-by-prettify"><br><br><br></span><span style=3D"color: #008;" class=3D"sty=
led-by-prettify">class</span><span style=3D"color: #000;" class=3D"styled-b=
y-prettify"> A </span><span style=3D"color: #660;" class=3D"styled-by-prett=
ify">:</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </s=
pan><span style=3D"color: #008;" class=3D"styled-by-prettify">public</span>=
<span style=3D"color: #000;" class=3D"styled-by-prettify"> A_members </span=
><span style=3D"color: #800;" class=3D"styled-by-prettify">//Inherit member=
s of 'class A ', currently produces compiler error, as unions can't be inhe=
rited</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br><=
/span><span style=3D"color: #660;" class=3D"styled-by-prettify">{</span><sp=
an style=3D"color: #000;" class=3D"styled-by-prettify"><br></span><span sty=
le=3D"color: #660;" class=3D"styled-by-prettify">};</span></div></code></di=
v><div><br></div><div>Or by using unnamed unions which however can't have '=
private' members so they are useless for now&nbsp;too&nbsp;:</div><div><br>=
<div><div style=3D"font-family: Arial, Helvetica, sans-serif; background-co=
lor: rgb(255, 255, 255);"><div class=3D"prettyprint" style=3D"border: 1px s=
olid rgb(187, 187, 187); word-wrap: break-word; background-color: rgb(250, =
250, 250);"><code class=3D"prettyprint"><div class=3D"subprettyprint"><div =
style=3D"font-family: Arial, Helvetica, sans-serif; background-color: rgb(2=
55, 255, 255);"><div><span style=3D"color: #008;" class=3D"styled-by-pretti=
fy">class</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> =
A</span></div><div><span style=3D"color: #660;" class=3D"styled-by-prettify=
">{</span></div><div><span style=3D"color: #000;" class=3D"styled-by-pretti=
fy"> &nbsp; &nbsp;</span><span style=3D"color: #008;" class=3D"styled-by-pr=
ettify">union</span><span style=3D"color: #000;" class=3D"styled-by-prettif=
y"> </span><span style=3D"color: #800;" class=3D"styled-by-prettify">//will=
 produce error, unnamed unions can't have private members</span></div><div>=
<span style=3D"color: #800;" class=3D"styled-by-prettify"> &nbsp; &nbsp;{</=
span></div><div><span style=3D"color: #800;" class=3D"styled-by-prettify"> =
&nbsp; &nbsp;private:</span></div><div><span style=3D"color: #800;" class=
=3D"styled-by-prettify"> &nbsp; &nbsp; &nbsp; &nbsp;</span><span style=3D"c=
olor: rgb(136, 0, 0);"><span style=3D"color: #800;" class=3D"styled-by-pret=
tify">struct {</span></span><span style=3D"color: rgb(136, 0, 0);"><span st=
yle=3D"color: #800;" class=3D"styled-by-prettify">int _a, _b, _c; }</span><=
span style=3D"color: #800;" class=3D"styled-by-prettify">;</span></span></d=
iv><div><span style=3D"color: #800;" class=3D"styled-by-prettify"> &nbsp; &=
nbsp;public:</span></div><div><span style=3D"color: #800;" class=3D"styled-=
by-prettify"> &nbsp; &nbsp; &nbsp; &nbsp;struct {</span><span style=3D"colo=
r: rgb(136, 0, 0);"><span style=3D"color: #800;" class=3D"styled-by-prettif=
y">const</span></span><span style=3D"color: rgb(136, 0, 0);"><span style=3D=
"color: #800;" class=3D"styled-by-prettify"> </span></span><span style=3D"c=
olor: rgb(136, 0, 0);"><span style=3D"color: #800;" class=3D"styled-by-pret=
tify">int a, b, c; };</span></span></div><div><span style=3D"color: #800;" =
class=3D"styled-by-prettify"> &nbsp; &nbsp;};</span></div><div><span style=
=3D"color: #800;" class=3D"styled-by-prettify">}</span></div></div></div></=
code></div></div><br></div></div><div>For now the only option is using a na=
med 'union' as a class member like this:<br><br><div class=3D"prettyprint" =
style=3D"border: 1px solid rgb(187, 187, 187); word-wrap: break-word; backg=
round-color: rgb(250, 250, 250);"><code class=3D"prettyprint"><div class=3D=
"subprettyprint"><div class=3D"subprettyprint">struct A</div><div class=3D"=
subprettyprint">{</div><div class=3D"subprettyprint">&nbsp; &nbsp; A() =3D =
default;</div><div class=3D"subprettyprint">&nbsp; &nbsp;&nbsp;</div><div c=
lass=3D"subprettyprint">&nbsp; &nbsp; union Name</div><div class=3D"subpret=
typrint">&nbsp; &nbsp; {</div><div class=3D"subprettyprint">&nbsp; &nbsp; &=
nbsp; &nbsp; Name() {};</div><div class=3D"subprettyprint">&nbsp; &nbsp; &n=
bsp; &nbsp;&nbsp;</div><div class=3D"subprettyprint">&nbsp; &nbsp; private:=
</div><div class=3D"subprettyprint">&nbsp; &nbsp; &nbsp; &nbsp; struct {int=
 _a, _b, _c; };</div><div class=3D"subprettyprint">&nbsp; &nbsp; public:</d=
iv><div class=3D"subprettyprint">&nbsp; &nbsp; &nbsp; &nbsp; struct {const =
int a, b, c; };</div><div class=3D"subprettyprint">&nbsp; &nbsp; &nbsp; &nb=
sp;&nbsp;</div><div class=3D"subprettyprint">&nbsp; &nbsp; friend class A;<=
/div><div class=3D"subprettyprint">&nbsp; &nbsp; } a_members;</div><div cla=
ss=3D"subprettyprint">&nbsp; &nbsp;&nbsp;</div><div class=3D"subprettyprint=
">&nbsp; &nbsp; void SomeMethod() { a_members._a =3D 9; } &nbsp; //uses the=
 'private' non-const version of 'a' in order to edit it &nbsp; &nbsp;&nbsp;=
</div><div class=3D"subprettyprint">};</div></div></code></div><div><br></d=
iv></div><div>And access 'A' members from '<span style=3D"color: rgb(0, 0, =
0); font-family: monospace; background-color: rgb(250, 250, 250);">a_member=
s</span>' which is somehow stupid but the best solution yet, preventing the=
 need to write getters and setters manually.<br><br>Life <a href=3D"http://=
melpon.org/wandbox/permlink/iTgOWnEuWkHa3ip5">example</a>.</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&quot; 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_1384_1832961126.1418479529388--
------=_Part_1383_592721016.1418479529387--

.