Topic: new featureplace a same old data with the new
Author: rmbeer2@gmail.com
Date: Sat, 14 Jul 2018 23:25:44 -0700 (PDT)
Raw View
------=_Part_127311_917147305.1531635944611
Content-Type: multipart/alternative;
boundary="----=_Part_127312_97413233.1531635944612"
------=_Part_127312_97413233.1531635944612
Content-Type: text/plain; charset="UTF-8"
This is based on the other thread:
https://groups.google.com/a/isocpp.org/forum/#!topic/std-proposals/dSAu_sbyEXA
I want to start with this new thread with a more complete proposal, since I
realize that you can not think for yourselves and much less study it.
This proposal has already defined the sentence that will be used in the
code.
The problematic situation that is intended to be solved is the following:
member
A ---------> B
| |
|inheritance | inheritance
| |
v member v
C ---------> D
Whose code is the following:
Code:
---------------------------------------
class A {
public:
A(int z_) : z(z_) { }
int z;
};
class C: public A {
public:
C(int y_) : y(y_), A(y_) { }
long y;
};
class B {
public:
B() : a(1) { }
void f2() {
std::cout << "A:" << a.z << std::endl;
}
virtual A a;
};
class D: public B {
public:
B() : a(3) { }
void f2() {
std::cout << "A:" << a.z << std::endl;
B::f2();
}
virtual C a;
};
int main(){
B b; D d;
b.f2(); d.f2();
return 0;
}
/* OUTPUT:
A:1
C+A:3
A:3
*/
---------------------------------------
DO NOT EXECUTE THIS CODE, IT DOES NOT WORK.
This code includes with the keyword to work on the operation of the
variable, what it does is replace "A a;" for "C a;" within the classes
defined at the time of the declaration of variables.
With class B declared in "b", it will contain the data of "A a;" (A). With
class D declared in "d", it will contain the data of "C a;" (C+A).
If the keyword "virtual" is omitted in the two variables declared "A a;"
and "C a;", declared class D will have an overload of variable "a" as
(C+A,A).
But with the keyword "virtual", the class D declared in the variable "d",
will have as variable "a" only (C+A), being used in D the content of the
data of C from (C+A) and in B the content of the data of A from (C+A).
ADVANTAGE:
- It allows the functions of the base class to use the data of an inherited
class, especially in the calls to functions of a member class.
- Lets inherit the class next to another class.
- It allows to share between classes any data of the base classes without
overloads.
- Internally it does not interfere with the assembly code and the data
structure.
RULES:
- "virtual" must be included in a class declaration about a variable.
- It only works with variables of the same name.
- Overlaying an inherited class with another inherited class should work as
a "union".
================================================================================
Esto esta basado en el otro hilo:
https://groups.google.com/a/isocpp.org/forum/#!topic/std-proposals/dSAu_sbyEXA
Quiero comenzar con este nuevo hilo con una propuesta mas completa, ya que
me doy cuenta que ustedes no pueden pensarlos por si mismos y mucho menos
estudiarlo.
Esta propuesta ya tiene definido incluso la setencia que se va a usar en el
codigo.
La situacion problematica que se pretende resolver es la siguiente:
member
A ---------> B
| |
|inheritance | inheritance
| |
v member v
C ---------> D
Cuyo codigo es el siguiente:
Code:
---------------------------------------
class A {
public:
A(int z_) : z(z_) { }
int z;
};
class C: public A {
public:
C(int y_) : y(y_), A(y_) { }
long y;
};
class B {
public:
B() : a(1) { }
void f2() {
std::cout << "A:" << a.z << std::endl;
}
virtual A a;
};
class D: public B {
public:
B() : a(3) { }
void f2() {
std::cout << "A:" << a.z << std::endl;
B::f2();
}
virtual C a;
};
int main(){
B b; D d;
b.f2(); d.f2();
return 0;
}
/* OUTPUT:
A:1
C+A:3
A:3
*/
---------------------------------------
NO EJECUTAR ESTE CODIGO, NO FUNCIONA.
Dicho codigo incluye con la palabra clave a trabajar en el funcionamiento
de la variable, que lo que hace es reemplazar "A a;" por "C a;" dentro de
las clases definidas en el momento de la declaracion de variables.
Con la clase B declarada en "b", contendra los datos de "A a;" (A). Con la
clase D declarada en "d", contendra los datos de "C a;" (C+A).
Si se omite la palabra clave "virtual" en las dos variables declaradas "A
a;" y "C a;", la clase D declarada tendra una sobrecarga de variable "a"
como (C+A,A).
Pero con la palabra clave "virtual", la clase D declarada en la varible
"d", tendra como variable "a" solo (C+A), siendo usado en D el contenido de
los datos de C desde (C+A) y en B el contenido de los datos de A desde
(C+A).
VENTAJAS:
- Permite a las funciones de la clase base el uso de los datos de una clase
heredada, sobre todo en los llamados a funciones de una clase miembro.
- Permite heredar la clase a la par de otra clase.
- Permite compartir entre clases cualquier datos de las clases bases sin
sobrecargas.
- Internamente no interfiere con el codigo de ensamblado y con la
estructura de datos.
REGLAS:
- Debe incluirse "virtual" en una declaracion de clase sobre una variable.
- Solo funciona con variables del mismo nombre.
- Superponer una clase heredada por otra clase heredada deberia funcionar
como "union".
--
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
To view this discussion on the web visit https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/58370075-8584-4d52-be3a-295aa2c8ce40%40isocpp.org.
------=_Part_127312_97413233.1531635944612
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr">This is based on the other thread: https://groups.google.c=
om/a/isocpp.org/forum/#!topic/std-proposals/dSAu_sbyEXA<br><br>I want to st=
art with this new thread with a more complete proposal, since I realize tha=
t you can not think for yourselves and much less study it.<br>This proposal=
has already defined the sentence that will be used in the code.<br><br>The=
problematic situation that is intended to be solved is the following:<br><=
br>=C2=A0=C2=A0 member<br>A ---------> B<br>|=C2=A0=C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 |<br>|inheritance | inheritance<br>=
|=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 |<br>v=
=C2=A0 member=C2=A0=C2=A0=C2=A0 v<br>C ---------> D<br><br>Whose code is=
the following:<br><br>Code:<br>---------------------------------------<br>=
<br>class A {<br>public:<br>=C2=A0=C2=A0=C2=A0 A(int z_) : z(z_) {=C2=A0=C2=
=A0=C2=A0 }<br>=C2=A0=C2=A0=C2=A0 int z;<br>};<br>class C: public A {<br>pu=
blic:<br>=C2=A0=C2=A0=C2=A0 C(int y_) : y(y_), A(y_) {=C2=A0=C2=A0=C2=A0 }<=
br>=C2=A0=C2=A0=C2=A0 long y;<br>};<br><br>class B {<br>public:<br>=C2=A0=
=C2=A0=C2=A0 B() : a(1) { }<br>=C2=A0=C2=A0=C2=A0 void f2() {<br>=C2=A0=C2=
=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 std::cout << "A:" <<=
; a.z << std::endl;<br>=C2=A0=C2=A0=C2=A0 }<br>=C2=A0=C2=A0=C2=A0 vir=
tual A a;<br>};<br>class D: public B {<br>public:<br>=C2=A0=C2=A0=C2=A0 B()=
: a(3) { }<br>=C2=A0=C2=A0=C2=A0 void f2() {<br>=C2=A0=C2=A0=C2=A0=C2=A0=
=C2=A0=C2=A0=C2=A0 std::cout << "A:" << a.z << =
std::endl;<br>=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 B::f2();<br>=C2=A0=
=C2=A0=C2=A0 }<br>=C2=A0=C2=A0=C2=A0 virtual C a;<br>};<br><br>int main(){<=
br>=C2=A0=C2=A0=C2=A0 B b; D d;<br>=C2=A0=C2=A0=C2=A0 b.f2(); d.f2();<br>=
=C2=A0=C2=A0=C2=A0 return 0;<br>}<br><br>/* OUTPUT:<br>A:1<br>C+A:3<br>A:3<=
br>*/<br>---------------------------------------<br><br>DO NOT EXECUTE THIS=
CODE, IT DOES NOT WORK.<br>This code includes with the keyword to work on =
the operation of the variable, what it does is replace "A a;" for=
"C a;" within the classes defined at the time of the declaration=
of variables.<br>With class B declared in "b", it will contain t=
he data of "A a;" (A). With class D declared in "d", it=
will contain the data of "C a;" (C+A).<br>If the keyword "v=
irtual" is omitted in the two variables declared "A a;" and =
"C a;", declared class D will have an overload of variable "=
a" as (C+A,A).<br>But with the keyword "virtual", the class =
D declared in the variable "d", will have as variable "a&quo=
t; only (C+A), being used in D the content of the data of C from (C+A) and =
in B the content of the data of A from (C+A).<br><br>ADVANTAGE:<br>- It all=
ows the functions of the base class to use the data of an inherited class, =
especially in the calls to functions of a member class.<br>- Lets inherit t=
he class next to another class.<br>- It allows to share between classes any=
data of the base classes without overloads.<br>- Internally it does not in=
terfere with the assembly code and the data structure.<br><br>RULES:<br>- &=
quot;virtual" must be included in a class declaration about a variable=
..<br>- It only works with variables of the same name.<br>- Overlaying an in=
herited class with another inherited class should work as a "union&quo=
t;.<br><br>=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D<br><br>Esto esta basado en el otro hilo: https:=
//groups.google.com/a/isocpp.org/forum/#!topic/std-proposals/dSAu_sbyEXA<br=
><br>Quiero comenzar con este nuevo hilo con una propuesta mas completa, ya=
que me doy cuenta que ustedes no pueden pensarlos por si mismos y mucho me=
nos estudiarlo.<br>Esta propuesta ya tiene definido incluso la setencia que=
se va a usar en el codigo.<br><br>La situacion problematica que se pretend=
e resolver es la siguiente:<br><br>=C2=A0=C2=A0 member<br>A ---------> B=
<br>|=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 |<b=
r>|inheritance | inheritance<br>|=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=
=C2=A0=C2=A0=C2=A0=C2=A0 |<br>v=C2=A0 member=C2=A0=C2=A0=C2=A0 v<br>C -----=
----> D<br><br>Cuyo codigo es el siguiente:<br><br>Code:<br>------------=
---------------------------<br><br>class A {<br>public:<br>=C2=A0=C2=A0=C2=
=A0 A(int z_) : z(z_) {=C2=A0=C2=A0=C2=A0 }<br>=C2=A0=C2=A0=C2=A0 int z;<br=
>};<br>class C: public A {<br>public:<br>=C2=A0=C2=A0=C2=A0 C(int y_) : y(y=
_), A(y_) {=C2=A0=C2=A0=C2=A0 }<br>=C2=A0=C2=A0=C2=A0 long y;<br>};<br><br>=
class B {<br>public:<br>=C2=A0=C2=A0=C2=A0 B() : a(1) { }<br>=C2=A0=C2=A0=
=C2=A0 void f2() {<br>=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 std::cout =
<< "A:" << a.z << std::endl;<br>=C2=A0=C2=A0=C2=
=A0 }<br>=C2=A0=C2=A0=C2=A0 virtual A a;<br>};<br>class D: public B {<br>pu=
blic:<br>=C2=A0=C2=A0=C2=A0 B() : a(3) { }<br>=C2=A0=C2=A0=C2=A0 void f2() =
{<br>=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 std::cout << "A:=
" << a.z << std::endl;<br>=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=
=C2=A0=C2=A0 B::f2();<br>=C2=A0=C2=A0=C2=A0 }<br>=C2=A0=C2=A0=C2=A0 virtual=
C a;<br>};<br><br>int main(){<br>=C2=A0=C2=A0=C2=A0 B b; D d;<br>=C2=A0=C2=
=A0=C2=A0 b.f2(); d.f2();<br>=C2=A0=C2=A0=C2=A0 return 0;<br>}<br><br>/* OU=
TPUT:<br>A:1<br>C+A:3<br>A:3<br>*/<br>-------------------------------------=
--<br><br>NO EJECUTAR ESTE CODIGO, NO FUNCIONA.<br>Dicho codigo incluye con=
la palabra clave a trabajar en el funcionamiento de la variable, que lo qu=
e hace es reemplazar "A a;" por "C a;" dentro de las cl=
ases definidas en el momento de la declaracion de variables.<br>Con la clas=
e B declarada en "b", contendra los datos de "A a;" (A)=
.. Con la clase D declarada en "d", contendra los datos de "C=
a;" (C+A).<br>Si se omite la palabra clave "virtual" en las=
dos variables declaradas "A a;" y "C a;", la clase D d=
eclarada tendra una sobrecarga de variable "a" como (C+A,A).<br>P=
ero con la palabra clave "virtual", la clase D declarada en la va=
rible "d", tendra como variable "a" solo (C+A), siendo =
usado en D el contenido de los datos de C desde (C+A) y en B el contenido d=
e los datos de A desde (C+A).<br><br>VENTAJAS:<br>- Permite a las funciones=
de la clase base el uso de los datos de una clase heredada, sobre todo en =
los llamados a funciones de una clase miembro.<br>- Permite heredar la clas=
e a la par de otra clase.<br>- Permite compartir entre clases cualquier dat=
os de las clases bases sin sobrecargas.<br>- Internamente no interfiere con=
el codigo de ensamblado y con la estructura de datos.<br><br>REGLAS:<br>- =
Debe incluirse "virtual" en una declaracion de clase sobre una va=
riable.<br>- Solo funciona con variables del mismo nombre.<br>- Superponer =
una clase heredada por otra clase heredada deberia funcionar como "uni=
on".<br><br></div>
<p></p>
-- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals" group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<br />
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/58370075-8584-4d52-be3a-295aa2c8ce40%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/58370075-8584-4d52-be3a-295aa2c8ce40=
%40isocpp.org</a>.<br />
------=_Part_127312_97413233.1531635944612--
------=_Part_127311_917147305.1531635944611--
.
Author: Henry Miller <hank@millerfarm.com>
Date: Sun, 15 Jul 2018 06:47:30 -0500
Raw View
This is a multi-part message in MIME format.
--_----------=_153165525017469860
Content-Type: text/plain; charset="UTF-8"
So you want this new syntax just so you don't have to type
D::D() : B() {a=3;}
I think that I just saved you a bunch of typing actually, unless D has a
lot of constructors and you can't delegate them for some reason.
I don't like it. It looks to me like all uses violate SOLID rules in
some way and thus are bad code.
--
Henry Miller
hank@millerfarm.com
On Sun, Jul 15, 2018, at 1:25 AM, rmbeer2@gmail.com wrote:
> This is based on the other thread:
> https://groups.google.com/a/isocpp.org/forum/#!topic/std-proposals/dSAu_sbyEXA>
> I want to start with this new thread with a more complete proposal,
> since I realize that you can not think for yourselves and much less
> study it.> This proposal has already defined the sentence that will be used in
> the code.>
> The problematic situation that is intended to be solved is the
> following:>
> member
> A ---------> B
> | |
> |inheritance | inheritance
> | |
> v member v
> C ---------> D
>
> Whose code is the following:
>
> Code:
> ---------------------------------------
>
> class A {
> public:
> A(int z_) : z(z_) { }
> int z;
> };
> class C: public A {
> public:
> C(int y_) : y(y_), A(y_) { }
> long y;
> };
>
> class B {
> public:
> B() : a(1) { }
> void f2() {
> std::cout << "A:" << a.z << std::endl;
> }
> virtual A a;
> };
> class D: public B {
> public:
> B() : a(3) { }
> void f2() {
> std::cout << "A:" << a.z << std::endl;
> B::f2();
> }
> virtual C a;
> };
>
> int main(){
> B b; D d;
> b.f2(); d.f2();
> return 0;
> }
>
> /* OUTPUT:
> A:1
> C+A:3
> A:3
> */
> ---------------------------------------
>
> DO NOT EXECUTE THIS CODE, IT DOES NOT WORK.
> This code includes with the keyword to work on the operation of the
> variable, what it does is replace "A a;" for "C a;" within the classes
> defined at the time of the declaration of variables.> With class B declared in "b", it will contain the data of "A a;"
> (A). With class D declared in "d", it will contain the data of "C
> a;" (C+A).> If the keyword "virtual" is omitted in the two variables declared "A
> a;" and "C a;", declared class D will have an overload of variable "a"
> as (C+A,A).> But with the keyword "virtual", the class D declared in the variable
> "d", will have as variable "a" only (C+A), being used in D the
> content of the data of C from (C+A) and in B the content of the data
> of A from (C+A).>
> ADVANTAGE:
> - It allows the functions of the base class to use the data of an
> inherited class, especially in the calls to functions of a member
> class.> - Lets inherit the class next to another class.
> - It allows to share between classes any data of the base classes
> without overloads.> - Internally it does not interfere with the assembly code and the data
> structure.>
> RULES:
> - "virtual" must be included in a class declaration about a variable.> - It only works with variables of the same name.
> - Overlaying an inherited class with another inherited class should
> work as a "union".>
> ================================================================================
>
> Esto esta basado en el otro hilo:
> https://groups.google.com/a/isocpp.org/forum/#!topic/std-proposals/dSAu_sbyEXA>
> Quiero comenzar con este nuevo hilo con una propuesta mas completa, ya
> que me doy cuenta que ustedes no pueden pensarlos por si mismos y
> mucho menos estudiarlo.> Esta propuesta ya tiene definido incluso la setencia que se va a usar
> en el codigo.>
> La situacion problematica que se pretende resolver es la siguiente:
>
> member
> A ---------> B
> | |
> |inheritance | inheritance
> | |
> v member v
> C ---------> D
>
> Cuyo codigo es el siguiente:
>
> Code:
> ---------------------------------------
>
> class A {
> public:
> A(int z_) : z(z_) { }
> int z;
> };
> class C: public A {
> public:
> C(int y_) : y(y_), A(y_) { }
> long y;
> };
>
> class B {
> public:
> B() : a(1) { }
> void f2() {
> std::cout << "A:" << a.z << std::endl;
> }
> virtual A a;
> };
> class D: public B {
> public:
> B() : a(3) { }
> void f2() {
> std::cout << "A:" << a.z << std::endl;
> B::f2();
> }
> virtual C a;
> };
>
> int main(){
> B b; D d;
> b.f2(); d.f2();
> return 0;
> }
>
> /* OUTPUT:
> A:1
> C+A:3
> A:3
> */
> ---------------------------------------
>
> NO EJECUTAR ESTE CODIGO, NO FUNCIONA.
> Dicho codigo incluye con la palabra clave a trabajar en el
> funcionamiento de la variable, que lo que hace es reemplazar "A a;"
> por "C a;" dentro de las clases definidas en el momento de la
> declaracion de variables.> Con la clase B declarada en "b", contendra los datos de "A a;" (A).
> Con la clase D declarada en "d", contendra los datos de "C a;" (C+A).> Si se omite la palabra clave "virtual" en las dos variables declaradas
> "A a;" y "C a;", la clase D declarada tendra una sobrecarga de
> variable "a" como (C+A,A).> Pero con la palabra clave "virtual", la clase D declarada en la
> varible "d", tendra como variable "a" solo (C+A), siendo usado en D el
> contenido de los datos de C desde (C+A) y en B el contenido de los
> datos de A desde (C+A).>
> VENTAJAS:
> - Permite a las funciones de la clase base el uso de los datos de una
> clase heredada, sobre todo en los llamados a funciones de una clase
> miembro.> - Permite heredar la clase a la par de otra clase.
> - Permite compartir entre clases cualquier datos de las clases bases
> sin sobrecargas.> - Internamente no interfiere con el codigo de ensamblado y con la
> estructura de datos.>
> REGLAS:
> - Debe incluirse "virtual" en una declaracion de clase sobre una
> variable.> - Solo funciona con variables del mismo nombre.
> - Superponer una clase heredada por otra clase heredada deberia
> funcionar como "union".>
> --
> You received this message because you are subscribed to the Google
> Groups "ISO C++ Standard - Future Proposals" group.> To unsubscribe from this group and stop receiving emails from it,
> send an email to std-proposals+unsubscribe@isocpp.org.> To post to this group, send email to std-proposals@isocpp.org.
> To view this discussion on the web visit
> https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/58370075-8584-4d52-be3a-295aa2c8ce40%40isocpp.org[1].
Links:
1. https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/58370075-8584-4d52-be3a-295aa2c8ce40%40isocpp.org?utm_medium=email&utm_source=footer
--
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
To view this discussion on the web visit https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/1531655250.1746986.1441234936.4FD1A49E%40webmail.messagingengine.com.
--_----------=_153165525017469860
Content-Transfer-Encoding: quoted-printable
Content-Type: text/html; charset="UTF-8"
<!DOCTYPE html>
<html>
<head>
<title></title>
<style type=3D"text/css">p.MsoNormal,p.MsoNoSpacing{margin:0}</style>
</head>
<body><div style=3D"font-family:Arial;">So you want this new syntax just so=
you don't have to type<br></div>
<div style=3D"font-family:Arial;"><br></div>
<div style=3D"font-family:Arial;">D::D() : B() {a=3D3;}<br></div>
<div style=3D"font-family:Arial;"><br></div>
<div style=3D"font-family:Arial;">I think that I just saved you a bunch of =
typing actually, unless D has a lot of constructors and you can't delegate =
them for some reason. <br></div>
<div style=3D"font-family:Arial;"><br></div>
<div style=3D"font-family:Arial;">I don't like it. It looks to me like all =
uses violate SOLID rules in some way and thus are bad code. </div>
<div style=3D"font-family:Arial;"><br></div>
<div id=3D"sig11221025"><div class=3D"signature">--<br></div>
<div class=3D"signature"> Henry Miller<br></div>
<div class=3D"signature"> hank@millerfarm.com<br></div>
<div class=3D"signature"><br></div>
</div>
<div><br></div>
<div><br></div>
<div>On Sun, Jul 15, 2018, at 1:25 AM, <a href=3D"mailto:rmbeer2@gmail.com"=
class=3D"">rmbeer2@gmail.com</a> wrote:<br></div>
<blockquote type=3D"cite"><div dir=3D"ltr"><div style=3D"font-family:Arial;=
">This is based on the other thread: https://groups.google.com/a/isocpp.org=
/forum/#!topic/std-proposals/dSAu_sbyEXA<br></div>
<div style=3D"font-family:Arial;"><br></div>
<div style=3D"font-family:Arial;">I want to start with this new thread with=
a more complete proposal, since I realize that you can not think for yours=
elves and much less study it.<br></div>
<div style=3D"font-family:Arial;">This proposal has already defined the sen=
tence that will be used in the code.<br></div>
<div style=3D"font-family:Arial;"><br></div>
<div style=3D"font-family:Arial;">The problematic situation that is intende=
d to be solved is the following:<br></div>
<div style=3D"font-family:Arial;"><br></div>
<div style=3D"font-family:Arial;"> member<br></div>
<div style=3D"font-family:Arial;">A ---------> B<br></div>
<div style=3D"font-family:Arial;">| &nbs=
p; |<br></div>
<div style=3D"font-family:Arial;">|inheritance | inheritance<br></div>
<div style=3D"font-family:Arial;">| &nbs=
p; |<br></div>
<div style=3D"font-family:Arial;">v member v<br></d=
iv>
<div style=3D"font-family:Arial;">C ---------> D<br></div>
<div style=3D"font-family:Arial;"><br></div>
<div style=3D"font-family:Arial;">Whose code is the following:<br></div>
<div style=3D"font-family:Arial;"><br></div>
<div style=3D"font-family:Arial;">Code:<br></div>
<div style=3D"font-family:Arial;">---------------------------------------<b=
r></div>
<div style=3D"font-family:Arial;"><br></div>
<div style=3D"font-family:Arial;">class A {<br></div>
<div style=3D"font-family:Arial;">public:<br></div>
<div style=3D"font-family:Arial;"> A(int z_) : z(z_) {&nb=
sp; }<br></div>
<div style=3D"font-family:Arial;"> int z;<br></div>
<div style=3D"font-family:Arial;">};<br></div>
<div style=3D"font-family:Arial;">class C: public A {<br></div>
<div style=3D"font-family:Arial;">public:<br></div>
<div style=3D"font-family:Arial;"> C(int y_) : y(y_), A(y=
_) { }<br></div>
<div style=3D"font-family:Arial;"> long y;<br></div>
<div style=3D"font-family:Arial;">};<br></div>
<div style=3D"font-family:Arial;"><br></div>
<div style=3D"font-family:Arial;">class B {<br></div>
<div style=3D"font-family:Arial;">public:<br></div>
<div style=3D"font-family:Arial;"> B() : a(1) { }<br></di=
v>
<div style=3D"font-family:Arial;"> void f2() {<br></div>
<div style=3D"font-family:Arial;">  =
; std::cout << "A:" << a.z << std::endl;<br></div>
<div style=3D"font-family:Arial;"> }<br></div>
<div style=3D"font-family:Arial;"> virtual A a;<br></div>
<div style=3D"font-family:Arial;">};<br></div>
<div style=3D"font-family:Arial;">class D: public B {<br></div>
<div style=3D"font-family:Arial;">public:<br></div>
<div style=3D"font-family:Arial;"> B() : a(3) { }<br></di=
v>
<div style=3D"font-family:Arial;"> void f2() {<br></div>
<div style=3D"font-family:Arial;">  =
; std::cout << "A:" << a.z << std::endl;<br></div>
<div style=3D"font-family:Arial;">  =
; B::f2();<br></div>
<div style=3D"font-family:Arial;"> }<br></div>
<div style=3D"font-family:Arial;"> virtual C a;<br></div>
<div style=3D"font-family:Arial;">};<br></div>
<div style=3D"font-family:Arial;"><br></div>
<div style=3D"font-family:Arial;">int main(){<br></div>
<div style=3D"font-family:Arial;"> B b; D d;<br></div>
<div style=3D"font-family:Arial;"> b.f2(); d.f2();<br></d=
iv>
<div style=3D"font-family:Arial;"> return 0;<br></div>
<div style=3D"font-family:Arial;">}<br></div>
<div style=3D"font-family:Arial;"><br></div>
<div style=3D"font-family:Arial;">/* OUTPUT:<br></div>
<div style=3D"font-family:Arial;">A:1<br></div>
<div style=3D"font-family:Arial;">C+A:3<br></div>
<div style=3D"font-family:Arial;">A:3<br></div>
<div style=3D"font-family:Arial;">*/<br></div>
<div style=3D"font-family:Arial;">---------------------------------------<b=
r></div>
<div style=3D"font-family:Arial;"><br></div>
<div style=3D"font-family:Arial;">DO NOT EXECUTE THIS CODE, IT DOES NOT WOR=
K.<br></div>
<div style=3D"font-family:Arial;">This code includes with the keyword to wo=
rk on the operation of the variable, what it does is replace "A a;" for "C =
a;" within the classes defined at the time of the declaration of variables.=
<br></div>
<div style=3D"font-family:Arial;">With class B declared in "b", it will con=
tain the data of "A a;" (A). With class D declared in "d", it will contain =
the data of "C a;" (C+A).<br></div>
<div style=3D"font-family:Arial;">If the keyword "virtual" is omitted in th=
e two variables declared "A a;" and "C a;", declared class D will have an o=
verload of variable "a" as (C+A,A).<br></div>
<div style=3D"font-family:Arial;">But with the keyword "virtual", the class=
D declared in the variable "d", will have as variable "a" only (C+A), bein=
g used in D the content of the data of C from (C+A) and in B the content of=
the data of A from (C+A).<br></div>
<div style=3D"font-family:Arial;"><br></div>
<div style=3D"font-family:Arial;">ADVANTAGE:<br></div>
<div style=3D"font-family:Arial;">- It allows the functions of the base cla=
ss to use the data of an inherited class, especially in the calls to functi=
ons of a member class.<br></div>
<div style=3D"font-family:Arial;">- Lets inherit the class next to another =
class.<br></div>
<div style=3D"font-family:Arial;">- It allows to share between classes any =
data of the base classes without overloads.<br></div>
<div style=3D"font-family:Arial;">- Internally it does not interfere with t=
he assembly code and the data structure.<br></div>
<div style=3D"font-family:Arial;"><br></div>
<div style=3D"font-family:Arial;">RULES:<br></div>
<div style=3D"font-family:Arial;">- "virtual" must be included in a class d=
eclaration about a variable.<br></div>
<div style=3D"font-family:Arial;">- It only works with variables of the sam=
e name.<br></div>
<div style=3D"font-family:Arial;">- Overlaying an inherited class with anot=
her inherited class should work as a "union".<br></div>
<div style=3D"font-family:Arial;"><br></div>
<div style=3D"font-family:Arial;">=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D<br></div>
<div style=3D"font-family:Arial;"><br></div>
<div style=3D"font-family:Arial;">Esto esta basado en el otro hilo: https:/=
/groups.google.com/a/isocpp.org/forum/#!topic/std-proposals/dSAu_sbyEXA<br>=
</div>
<div style=3D"font-family:Arial;"><br></div>
<div style=3D"font-family:Arial;">Quiero comenzar con este nuevo hilo con u=
na propuesta mas completa, ya que me doy cuenta que ustedes no pueden pensa=
rlos por si mismos y mucho menos estudiarlo.<br></div>
<div style=3D"font-family:Arial;">Esta propuesta ya tiene definido incluso =
la setencia que se va a usar en el codigo.<br></div>
<div style=3D"font-family:Arial;"><br></div>
<div style=3D"font-family:Arial;">La situacion problematica que se pretende=
resolver es la siguiente:<br></div>
<div style=3D"font-family:Arial;"><br></div>
<div style=3D"font-family:Arial;"> member<br></div>
<div style=3D"font-family:Arial;">A ---------> B<br></div>
<div style=3D"font-family:Arial;">| &nbs=
p; |<br></div>
<div style=3D"font-family:Arial;">|inheritance | inheritance<br></div>
<div style=3D"font-family:Arial;">| &nbs=
p; |<br></div>
<div style=3D"font-family:Arial;">v member v<br></d=
iv>
<div style=3D"font-family:Arial;">C ---------> D<br></div>
<div style=3D"font-family:Arial;"><br></div>
<div style=3D"font-family:Arial;">Cuyo codigo es el siguiente:<br></div>
<div style=3D"font-family:Arial;"><br></div>
<div style=3D"font-family:Arial;">Code:<br></div>
<div style=3D"font-family:Arial;">---------------------------------------<b=
r></div>
<div style=3D"font-family:Arial;"><br></div>
<div style=3D"font-family:Arial;">class A {<br></div>
<div style=3D"font-family:Arial;">public:<br></div>
<div style=3D"font-family:Arial;"> A(int z_) : z(z_) {&nb=
sp; }<br></div>
<div style=3D"font-family:Arial;"> int z;<br></div>
<div style=3D"font-family:Arial;">};<br></div>
<div style=3D"font-family:Arial;">class C: public A {<br></div>
<div style=3D"font-family:Arial;">public:<br></div>
<div style=3D"font-family:Arial;"> C(int y_) : y(y_), A(y=
_) { }<br></div>
<div style=3D"font-family:Arial;"> long y;<br></div>
<div style=3D"font-family:Arial;">};<br></div>
<div style=3D"font-family:Arial;"><br></div>
<div style=3D"font-family:Arial;">class B {<br></div>
<div style=3D"font-family:Arial;">public:<br></div>
<div style=3D"font-family:Arial;"> B() : a(1) { }<br></di=
v>
<div style=3D"font-family:Arial;"> void f2() {<br></div>
<div style=3D"font-family:Arial;">  =
; std::cout << "A:" << a.z << std::endl;<br></div>
<div style=3D"font-family:Arial;"> }<br></div>
<div style=3D"font-family:Arial;"> virtual A a;<br></div>
<div style=3D"font-family:Arial;">};<br></div>
<div style=3D"font-family:Arial;">class D: public B {<br></div>
<div style=3D"font-family:Arial;">public:<br></div>
<div style=3D"font-family:Arial;"> B() : a(3) { }<br></di=
v>
<div style=3D"font-family:Arial;"> void f2() {<br></div>
<div style=3D"font-family:Arial;">  =
; std::cout << "A:" << a.z << std::endl;<br></div>
<div style=3D"font-family:Arial;">  =
; B::f2();<br></div>
<div style=3D"font-family:Arial;"> }<br></div>
<div style=3D"font-family:Arial;"> virtual C a;<br></div>
<div style=3D"font-family:Arial;">};<br></div>
<div style=3D"font-family:Arial;"><br></div>
<div style=3D"font-family:Arial;">int main(){<br></div>
<div style=3D"font-family:Arial;"> B b; D d;<br></div>
<div style=3D"font-family:Arial;"> b.f2(); d.f2();<br></d=
iv>
<div style=3D"font-family:Arial;"> return 0;<br></div>
<div style=3D"font-family:Arial;">}<br></div>
<div style=3D"font-family:Arial;"><br></div>
<div style=3D"font-family:Arial;">/* OUTPUT:<br></div>
<div style=3D"font-family:Arial;">A:1<br></div>
<div style=3D"font-family:Arial;">C+A:3<br></div>
<div style=3D"font-family:Arial;">A:3<br></div>
<div style=3D"font-family:Arial;">*/<br></div>
<div style=3D"font-family:Arial;">---------------------------------------<b=
r></div>
<div style=3D"font-family:Arial;"><br></div>
<div style=3D"font-family:Arial;">NO EJECUTAR ESTE CODIGO, NO FUNCIONA.<br>=
</div>
<div style=3D"font-family:Arial;">Dicho codigo incluye con la palabra clave=
a trabajar en el funcionamiento de la variable, que lo que hace es reempla=
zar "A a;" por "C a;" dentro de las clases definidas en el momento de la de=
claracion de variables.<br></div>
<div style=3D"font-family:Arial;">Con la clase B declarada en "b", contendr=
a los datos de "A a;" (A). Con la clase D declarada en "d", contendra los d=
atos de "C a;" (C+A).<br></div>
<div style=3D"font-family:Arial;">Si se omite la palabra clave "virtual" en=
las dos variables declaradas "A a;" y "C a;", la clase D declarada tendra =
una sobrecarga de variable "a" como (C+A,A).<br></div>
<div style=3D"font-family:Arial;">Pero con la palabra clave "virtual", la c=
lase D declarada en la varible "d", tendra como variable "a" solo (C+A), si=
endo usado en D el contenido de los datos de C desde (C+A) y en B el conten=
ido de los datos de A desde (C+A).<br></div>
<div style=3D"font-family:Arial;"><br></div>
<div style=3D"font-family:Arial;">VENTAJAS:<br></div>
<div style=3D"font-family:Arial;">- Permite a las funciones de la clase bas=
e el uso de los datos de una clase heredada, sobre todo en los llamados a f=
unciones de una clase miembro.<br></div>
<div style=3D"font-family:Arial;">- Permite heredar la clase a la par de ot=
ra clase.<br></div>
<div style=3D"font-family:Arial;">- Permite compartir entre clases cualquie=
r datos de las clases bases sin sobrecargas.<br></div>
<div style=3D"font-family:Arial;">- Internamente no interfiere con el codig=
o de ensamblado y con la estructura de datos.<br></div>
<div style=3D"font-family:Arial;"><br></div>
<div style=3D"font-family:Arial;">REGLAS:<br></div>
<div style=3D"font-family:Arial;">- Debe incluirse "virtual" en una declara=
cion de clase sobre una variable.<br></div>
<div style=3D"font-family:Arial;">- Solo funciona con variables del mismo n=
ombre.<br></div>
<div style=3D"font-family:Arial;">- Superponer una clase heredada por otra =
clase heredada deberia funcionar como "union".<br></div>
</div>
<p><br></p><div style=3D"font-family:Arial;">--<br></div>
<div style=3D"font-family:Arial;"> You received this message because you ar=
e subscribed to the Google Groups "ISO C++ Standard - Future Proposals" gro=
up.<br></div>
<div style=3D"font-family:Arial;"> To unsubscribe from this group and stop =
receiving emails from it, send an email to <a href=3D"mailto:std-proposals+=
unsubscribe@isocpp.org">std-proposals+unsubscribe@isocpp.org</a>.<br></div>
<div style=3D"font-family:Arial;"> To post to this group, send email to <a =
href=3D"mailto:std-proposals@isocpp.org">std-proposals@isocpp.org</a>.<br><=
/div>
<div style=3D"font-family:Arial;"> To view this discussion on the web visit=
<a href=3D"https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/58=
370075-8584-4d52-be3a-295aa2c8ce40%40isocpp.org?utm_medium=3Demail&utm_=
source=3Dfooter">https://groups.google.com/a/isocpp.org/d/msgid/std-proposa=
ls/58370075-8584-4d52-be3a-295aa2c8ce40%40isocpp.org</a>.<br></div>
</blockquote></body>
</html>
<p></p>
-- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals" group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<br />
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/1531655250.1746986.1441234936.4FD1A49=
E%40webmail.messagingengine.com?utm_medium=3Demail&utm_source=3Dfooter">htt=
ps://groups.google.com/a/isocpp.org/d/msgid/std-proposals/1531655250.174698=
6.1441234936.4FD1A49E%40webmail.messagingengine.com</a>.<br />
--_----------=_153165525017469860--
.
Author: Nicol Bolas <jmckesson@gmail.com>
Date: Sun, 15 Jul 2018 09:19:49 -0700 (PDT)
Raw View
------=_Part_157885_1937005868.1531671589807
Content-Type: multipart/alternative;
boundary="----=_Part_157886_320139548.1531671589807"
------=_Part_157886_320139548.1531671589807
Content-Type: text/plain; charset="UTF-8"
On Sunday, July 15, 2018 at 2:25:44 AM UTC-4, rmb...@gmail.com wrote:
>
> This is based on the other thread:
> https://groups.google.com/a/isocpp.org/forum/#!topic/std-proposals/dSAu_sbyEXA
>
> I want to start with this new thread with a more complete proposal, since
> I realize that you can not think for yourselves and much less study it.
>
For what it's worth, nobody misunderstood your previous thread. We
understood what you were asking for just fine. We get it.
The solution simply does not provide enough value. The problem it purports
to solve is not encountered by a significant number of C++ coders. And the
code examples you've provided as motivation represent coding styles that
are incoherent or otherwise are things we would rather people not be doing.
That is, this problem is mainly encountered in badly designed systems; it's
best to avoid bad design rather than to create a feature that allows it.
At the very least, your example of the problem is sufficiently abstract
that the primary question I have is "why are you writing your code that
way? Why is D inheriting from these things? What is this saying about the
relationships between these objects?" Providing an example culled from a
real program would make for a more convincing argument than this
hypothetical A/B/C/D example.
There are also implementation questions to consider. Using your A/B/C/D
example, how exactly does this work? This seems like a virtual base class
kind of thing, only with members.
So... what is `sizeof(B)`? That has to be a static value, fixed at compile
time. `B` obviously has a vtable pointer or whatever other machinery is
needed to implement virtual functionality. But does `B` reserve sufficient
space to store an `A` within it? Because if it does, then *every* `B` must
have that space. Even `D::B` still must have enough space to store an `A`,
even though `D::B::a` doesn't access that space.
That's not a good thing.
Furthermore, like virtual inheritance, the question of when `D::B::a`
starts pointing to `D::a::A` starts becoming relevant. For example, with
normal `virtual` functions, in `B`'s constructor, calling virtual functions
will only call overrides in `B`; if `D` overrode any virtuals from `B`,
they would not be called from `B`'s constructors.
Presumably, virtual members would work the same way. This reinforces the
fact that `B` must always have sufficient storage for `B::a` within itself.
Why? Because `B`'s constructor does not know that it was called as a base
class. Therefore, it must initialize its member subobjects, so it will
always initialize `B::a`. And it will never actually use it (unless someone
uses `this->B::a`, just as with calling a specific virtual function).
So your `D` class will indeed have two `a` subobjects. It's just that one
of them is much more difficult to access.
At the end of the day, this would be more efficiently done *manually* than
with a `virtual` value system. That is, you do this:
class B_base
{
public:
virtual A& get_a() = 0;
virtual const A& get_a() const = 0;
};
class B : public B_base
{
public:
A a = 1;
virtual A& get_a() override final {return a;}
virtual const A& get_a() const override final {return a;}
};
class D : public B_base
{
public:
virtual A& get_a() override {return a;}
virtual const A& get_a() const override {return a;}
C a = 3;
};
`B` is for standalone usage (which is why its overrides are `final`);
`B_base` is what you use when you're deriving a class. And `B_base` is what
most functions should take as arguments if they want polymorphism.
So what is the motivation for your proposal? The above code is more
efficient. So why would you not do it? Because you have to type `get_a` to
get at the variable?
--
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
To view this discussion on the web visit https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/806f0ee4-776f-43aa-aad8-e439d89892a7%40isocpp.org.
------=_Part_157886_320139548.1531671589807
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr">On Sunday, July 15, 2018 at 2:25:44 AM UTC-4, rmb...@gmail=
..com wrote:<blockquote class=3D"gmail_quote" style=3D"margin: 0;margin-left=
: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;"><div dir=3D"ltr">Th=
is is based on the other thread: <a href=3D"https://groups.google.com/a/iso=
cpp.org/forum/#!topic/std-proposals/dSAu_sbyEXA" target=3D"_blank" rel=3D"n=
ofollow" onmousedown=3D"this.href=3D'https://groups.google.com/a/isocpp=
..org/forum/#!topic/std-proposals/dSAu_sbyEXA';return true;" onclick=3D"=
this.href=3D'https://groups.google.com/a/isocpp.org/forum/#!topic/std-p=
roposals/dSAu_sbyEXA';return true;">https://groups.google.com/a/<wbr>is=
ocpp.org/forum/#!topic/std-<wbr>proposals/dSAu_sbyEXA</a><br><br>I want to =
start with this new thread with a more complete proposal, since I realize t=
hat you can not think for yourselves and much less study it.<br></div></blo=
ckquote><div><br></div><div>For what it's worth, nobody misunderstood y=
our previous thread. We understood what you were asking for just fine. We g=
et it.</div><div><br></div><div>The solution simply does not provide enough=
value. The problem it purports to solve is not encountered by a significan=
t number of C++ coders. And the code examples you've provided as motiva=
tion represent coding styles that are incoherent or otherwise are things we=
would rather people not be doing. That is, this problem is mainly encounte=
red in badly designed systems; it's best to avoid bad design rather tha=
n to create a feature that allows it.<br></div><div><br></div><div>At the v=
ery least, your example of the problem is sufficiently abstract that the pr=
imary question I have is "why are you writing your code that way? Why =
is D inheriting from these things? What is this saying about the relationsh=
ips between these objects?" Providing an example culled from a real pr=
ogram would make for a more convincing argument than this hypothetical A/B/=
C/D example.</div><div><br></div><div>There are also implementation questio=
ns to consider. Using your A/B/C/D example, how exactly does this work? Thi=
s seems like a virtual base class kind of thing, only with members.</div><d=
iv><br></div><div>So... what is `sizeof(B)`? That has to be a static value,=
fixed at compile time. `B` obviously has a vtable pointer or whatever othe=
r machinery is needed to implement virtual functionality. But does `B` rese=
rve sufficient space to store an `A` within it? Because if it does, then <i=
>every</i> `B` must have that space. Even `D::B` still must have enough spa=
ce to store an `A`, even though `D::B::a` doesn't access that space.</d=
iv><div><br></div><div>That's not a good thing.</div><div><br></div><di=
v>Furthermore, like virtual inheritance, the question of when `D::B::a` sta=
rts pointing to `D::a::A` starts becoming relevant. For example, with norma=
l `virtual` functions, in `B`'s constructor, calling virtual functions =
will only call overrides in `B`; if `D` overrode any virtuals from `B`, the=
y would not be called from `B`'s constructors.</div><div><br></div><div=
>Presumably, virtual members would work the same way. This reinforces the f=
act that `B` must always have sufficient storage for `B::a` within itself. =
Why? Because `B`'s constructor does not know that it was called as a ba=
se class. Therefore, it must initialize its member subobjects, so it will a=
lways initialize `B::a`. And it will never actually use it (unless someone =
uses `this->B::a`, just as with calling a specific virtual function).</d=
iv><div><br></div><div>So your `D` class will indeed have two `a` subobject=
s. It's just that one of them is much more difficult to access.<br></di=
v><div><br></div><div>At the end of the day, this would be more efficiently=
done <i>manually</i> than with a `virtual` value system. That is, you do t=
his:</div><div><br></div><div style=3D"background-color: rgb(250, 250, 250)=
; border-color: rgb(187, 187, 187); border-style: solid; border-width: 1px;=
overflow-wrap: break-word;" class=3D"prettyprint"><code class=3D"prettypri=
nt"><div class=3D"subprettyprint"><span style=3D"color: #008;" class=3D"sty=
led-by-prettify">class</span><span style=3D"color: #000;" class=3D"styled-b=
y-prettify"> B_base<br></span><span style=3D"color: #660;" class=3D"styled-=
by-prettify">{</span><span style=3D"color: #000;" class=3D"styled-by-pretti=
fy"><br></span><span style=3D"color: #008;" class=3D"styled-by-prettify">pu=
blic</span><span style=3D"color: #660;" class=3D"styled-by-prettify">:</spa=
n><span style=3D"color: #000;" class=3D"styled-by-prettify"><br>=C2=A0 </sp=
an><span style=3D"color: #008;" class=3D"styled-by-prettify">virtual</span>=
<span style=3D"color: #000;" class=3D"styled-by-prettify"> A</span><span st=
yle=3D"color: #660;" class=3D"styled-by-prettify">&</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"> get_a</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;" cla=
ss=3D"styled-by-prettify">=3D</span><span style=3D"color: #000;" class=3D"s=
tyled-by-prettify"> </span><span style=3D"color: #066;" class=3D"styled-by-=
prettify">0</span><span style=3D"color: #660;" class=3D"styled-by-prettify"=
>;</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br>=C2=
=A0 </span><span style=3D"color: #008;" class=3D"styled-by-prettify">virtua=
l</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><=
span style=3D"color: #008;" class=3D"styled-by-prettify">const</span><span =
style=3D"color: #000;" class=3D"styled-by-prettify"> A</span><span style=3D=
"color: #660;" class=3D"styled-by-prettify">&</span><span style=3D"colo=
r: #000;" class=3D"styled-by-prettify"> get_a</span><span style=3D"color: #=
660;" class=3D"styled-by-prettify">()</span><span style=3D"color: #000;" cl=
ass=3D"styled-by-prettify"> </span><span style=3D"color: #008;" class=3D"st=
yled-by-prettify">const</span><span style=3D"color: #000;" class=3D"styled-=
by-prettify"> </span><span style=3D"color: #660;" class=3D"styled-by-pretti=
fy">=3D</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </=
span><span style=3D"color: #066;" class=3D"styled-by-prettify">0</span><spa=
n 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><span style=3D"color: #00=
0;" class=3D"styled-by-prettify"><br><br></span><span style=3D"color: #008;=
" class=3D"styled-by-prettify">class</span><span style=3D"color: #000;" cla=
ss=3D"styled-by-prettify"> B </span><span style=3D"color: #660;" class=3D"s=
tyled-by-prettify">:</span><span style=3D"color: #000;" class=3D"styled-by-=
prettify"> </span><span style=3D"color: #008;" class=3D"styled-by-prettify"=
>public</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> B_=
base<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-prettify">public</span><spa=
n style=3D"color: #660;" class=3D"styled-by-prettify">:</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"><br>=C2=A0 A 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"styled-by-prettify">1</span><span style=3D"color: #660;" =
class=3D"styled-by-prettify">;</span><span style=3D"color: #000;" class=3D"=
styled-by-prettify"><br><br>=C2=A0 </span><span style=3D"color: #008;" clas=
s=3D"styled-by-prettify">virtual</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"> A</span><span style=3D"color: #660;" class=3D"styl=
ed-by-prettify">&</span><span style=3D"color: #000;" class=3D"styled-by=
-prettify"> get_a</span><span style=3D"color: #660;" class=3D"styled-by-pre=
ttify">()</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> =
</span><span style=3D"color: #008;" class=3D"styled-by-prettify">override</=
span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><spa=
n style=3D"color: #008;" class=3D"styled-by-prettify">final</span><span sty=
le=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"col=
or: #660;" class=3D"styled-by-prettify">{</span><span style=3D"color: #008;=
" class=3D"styled-by-prettify">return</span><span style=3D"color: #000;" cl=
ass=3D"styled-by-prettify"> a</span><span style=3D"color: #660;" class=3D"s=
tyled-by-prettify">;}</span><span style=3D"color: #000;" class=3D"styled-by=
-prettify"><br>=C2=A0 </span><span style=3D"color: #008;" class=3D"styled-b=
y-prettify">virtual</span><span style=3D"color: #000;" class=3D"styled-by-p=
rettify"> </span><span style=3D"color: #008;" class=3D"styled-by-prettify">=
const</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> A</s=
pan><span style=3D"color: #660;" class=3D"styled-by-prettify">&</span><=
span style=3D"color: #000;" class=3D"styled-by-prettify"> get_a</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">const</span><span style=3D"color: #00=
0;" class=3D"styled-by-prettify"> </span><span style=3D"color: #008;" class=
=3D"styled-by-prettify">override</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"><code class=3D"prettyprint"><span style=3D"color: #=
008;" class=3D"styled-by-prettify"> final</span><span style=3D"color: #660;=
" class=3D"styled-by-prettify"></span></code> </span><span style=3D"color: =
#660;" class=3D"styled-by-prettify">{</span><span style=3D"color: #008;" cl=
ass=3D"styled-by-prettify">return</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"> a</span><span style=3D"color: #660;" class=3D"styl=
ed-by-prettify">;}</span><span style=3D"color: #000;" class=3D"styled-by-pr=
ettify"><br></span><span style=3D"color: #660;" class=3D"styled-by-prettify=
">};</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br><b=
r></span><span style=3D"color: #008;" class=3D"styled-by-prettify">class</s=
pan><span style=3D"color: #000;" class=3D"styled-by-prettify"> D </span><sp=
an style=3D"color: #660;" class=3D"styled-by-prettify">:</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color=
: #008;" class=3D"styled-by-prettify">public</span><span style=3D"color: #0=
00;" class=3D"styled-by-prettify"> B_base<br></span><span style=3D"color: #=
660;" class=3D"styled-by-prettify">{</span><span style=3D"color: #000;" cla=
ss=3D"styled-by-prettify"><br></span><span style=3D"color: #008;" class=3D"=
styled-by-prettify">public</span><span style=3D"color: #660;" class=3D"styl=
ed-by-prettify">:</span><span style=3D"color: #000;" class=3D"styled-by-pre=
ttify"><br>=C2=A0 </span><span style=3D"color: #008;" class=3D"styled-by-pr=
ettify">virtual</span><span style=3D"color: #000;" class=3D"styled-by-prett=
ify"> A</span><span style=3D"color: #660;" class=3D"styled-by-prettify">&am=
p;</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> get_a</=
span><span style=3D"color: #660;" class=3D"styled-by-prettify">()</span><sp=
an style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=
=3D"color: #008;" class=3D"styled-by-prettify">override</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">return</span><span style=3D"color: #000;" clas=
s=3D"styled-by-prettify"> a</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>=C2=A0 </span><span style=3D"color: #008;" class=3D"styled-by-=
prettify">virtual</span><span style=3D"color: #000;" class=3D"styled-by-pre=
ttify"> </span><span style=3D"color: #008;" class=3D"styled-by-prettify">co=
nst</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> A</spa=
n><span style=3D"color: #660;" class=3D"styled-by-prettify">&</span><sp=
an style=3D"color: #000;" class=3D"styled-by-prettify"> get_a</span><span s=
tyle=3D"color: #660;" class=3D"styled-by-prettify">()</span><span style=3D"=
color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #0=
08;" 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">override</span><span style=3D"color: #000;" class=3D"st=
yled-by-prettify"> </span><span style=3D"color: #660;" class=3D"styled-by-p=
rettify">{</span><span style=3D"color: #008;" class=3D"styled-by-prettify">=
return</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> a</=
span><span style=3D"color: #660;" class=3D"styled-by-prettify">;}</span><sp=
an style=3D"color: #000;" class=3D"styled-by-prettify"><br><br>=C2=A0 C 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 styl=
e=3D"color: #066;" class=3D"styled-by-prettify">3</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><div><div><br></div><di=
v>`B` is for standalone usage (which is why its overrides are `final`); `B_=
base` is what you use when you're deriving a class. And `B_base` is wha=
t most functions should take as arguments if they want polymorphism.</div><=
div><br></div><div>So what is the motivation for your proposal? The above c=
ode is more efficient. So why would you not do it? Because you have to type=
`get_a` to get at the variable?<br></div></div></div>
<p></p>
-- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals" group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<br />
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/806f0ee4-776f-43aa-aad8-e439d89892a7%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/806f0ee4-776f-43aa-aad8-e439d89892a7=
%40isocpp.org</a>.<br />
------=_Part_157886_320139548.1531671589807--
------=_Part_157885_1937005868.1531671589807--
.
Author: rmbeer2@gmail.com
Date: Tue, 17 Jul 2018 22:54:40 -0700 (PDT)
Raw View
------=_Part_34609_1171648708.1531893280231
Content-Type: multipart/alternative;
boundary="----=_Part_34610_1702305938.1531893280232"
------=_Part_34610_1702305938.1531893280232
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
The value it provides is as high as the inheritances. This idea applies an=
=20
inheritance with simultaneous classes. Solve many of the problems of coding=
=20
interrelated classes, obviously I will not be collecting signatures or=20
creating a community around this idea, it is just very useful and you must=
=20
accept it. Nobody will come to complain about the impossibilities, in fact=
=20
I'm just seeing that many users prefer to move to another language than to=
=20
improve C++.
As you apply the inheritance for some reason, you need to apply the=20
inheritance in multiple classes at the same time.
In this thread example I have never mentioned sizeof(). The values =E2=80=
=8B=E2=80=8Bset=20
for the classes will be static after compilation, so a member class=20
declared as virtual should not be reserved beyond the last class declared.=
=20
Thus D will have as member (C+A), while B will have as a member only (A).=
=20
In fact this feature uses less space than normal as opposed to (C+A,A).
I think you're confusing things. How are the data stacked?
Mira esto:
(gdb) print b
$1 =3D {a =3D {z =3D 1}}
(gdb) print d
$2 =3D {<B> =3D {a =3D {z =3D 1}}, a =3D {<A> =3D {z =3D 3}, y =3D 3}}
By using 'virtual' on a variable you can simplify '<A> =3D {z =3D 3}' with =
'a =3D=20
{z =3D 1}', I do not know if I explain it, every time a call is made to the=
=20
function of class A is only covering the use of this data and no other, so=
=20
you can easily point to only one memory space.
And another thing, when calling from any function from B/D to A/C, the A/C=
=20
function forgets the data of B/D, it is not covering it.
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D
El valor que proporciona es tan alta como las herencias. Esta idea aplica=
=20
una herencia con clases simultaneas. Resuelve muchos de los problemas de=20
codificaci=C3=B3n de clases interrelacionadas, obviamente no voy a estar=20
juntando firmas o creando una comunidad alrededor de esta idea, simplemente=
=20
es muy util y debes aceptarlo. Nadie te va a venir a quejarse de las=20
imposibilidades, de hecho solo estoy viendo que muchos usuarios prefieren=
=20
mudarse a otro lenguaje que mejorar C++.
Asi como aplicas la herencia por algun motivo, necesitas aplicar la=20
herencia en multiples clases al mismo tiempo.
En este ejemplo del hilo nunca he mencionado a sizeof(). Los valores=20
fijados para las clases seran estaticos luego de la compilaci=C3=B3n, por l=
o que=20
una clase miembro declarada como virtual no deberia reservarse mas alla que=
=20
en la ultima clase declarada. Asi D tendra como miembro (C+A), mientras que=
=20
B tendra como miembro solo (A). De hecho esta caracteristica usa menos=20
espacio de lo normal al contrario de (C+A,A).
Creo que estas confundiendo las cosas. Como se apilan los datos?
Mira esto:
(gdb) print b
$1 =3D {a =3D {z =3D 1}}
(gdb) print d
$2 =3D {<B> =3D {a =3D {z =3D 1}}, a =3D {<A> =3D {z =3D 3}, y =3D 3}}
Con utilizar 'virtual' sobre una variable se puede simplificar '<A> =3D {z =
=3D=20
3}' con 'a =3D {z =3D 1}', no se si me explico, cada vez que se hace un lla=
mado=20
a la funcion de la clase A solo esta abarcando el uso a estos datos y a=20
ningun otro, por lo que facilmente se puede apuntar a solo un espacio de=20
memoria.
Y otra cosa, cuando se llama desde cualquier funcion de B/D a A/C, la=20
funcion de A/C se olvida de los datos de B/D, no la esta abarcando.
El domingo, 15 de julio de 2018, 13:19:49 (UTC-3), Nicol Bolas escribi=C3=
=B3:
>
> On Sunday, July 15, 2018 at 2:25:44 AM UTC-4, rmb...@gmail.com wrote:
>>
>> This is based on the other thread:=20
>> https://groups.google.com/a/isocpp.org/forum/#!topic/std-proposals/dSAu_=
sbyEXA
>>
>> I want to start with this new thread with a more complete proposal, sinc=
e=20
>> I realize that you can not think for yourselves and much less study it.
>>
>
> For what it's worth, nobody misunderstood your previous thread. We=20
> understood what you were asking for just fine. We get it.
>
> The solution simply does not provide enough value. The problem it purport=
s=20
> to solve is not encountered by a significant number of C++ coders. And th=
e=20
> code examples you've provided as motivation represent coding styles that=
=20
> are incoherent or otherwise are things we would rather people not be doin=
g.=20
> That is, this problem is mainly encountered in badly designed systems; it=
's=20
> best to avoid bad design rather than to create a feature that allows it.
>
> At the very least, your example of the problem is sufficiently abstract=
=20
> that the primary question I have is "why are you writing your code that=
=20
> way? Why is D inheriting from these things? What is this saying about the=
=20
> relationships between these objects?" Providing an example culled from a=
=20
> real program would make for a more convincing argument than this=20
> hypothetical A/B/C/D example.
>
> There are also implementation questions to consider. Using your A/B/C/D=
=20
> example, how exactly does this work? This seems like a virtual base class=
=20
> kind of thing, only with members.
>
> So... what is `sizeof(B)`? That has to be a static value, fixed at compil=
e=20
> time. `B` obviously has a vtable pointer or whatever other machinery is=
=20
> needed to implement virtual functionality. But does `B` reserve sufficien=
t=20
> space to store an `A` within it? Because if it does, then *every* `B`=20
> must have that space. Even `D::B` still must have enough space to store a=
n=20
> `A`, even though `D::B::a` doesn't access that space.
>
> That's not a good thing.
>
> Furthermore, like virtual inheritance, the question of when `D::B::a`=20
> starts pointing to `D::a::A` starts becoming relevant. For example, with=
=20
> normal `virtual` functions, in `B`'s constructor, calling virtual functio=
ns=20
> will only call overrides in `B`; if `D` overrode any virtuals from `B`,=
=20
> they would not be called from `B`'s constructors.
>
> Presumably, virtual members would work the same way. This reinforces the=
=20
> fact that `B` must always have sufficient storage for `B::a` within itsel=
f.=20
> Why? Because `B`'s constructor does not know that it was called as a base=
=20
> class. Therefore, it must initialize its member subobjects, so it will=20
> always initialize `B::a`. And it will never actually use it (unless someo=
ne=20
> uses `this->B::a`, just as with calling a specific virtual function).
>
> So your `D` class will indeed have two `a` subobjects. It's just that one=
=20
> of them is much more difficult to access.
>
> At the end of the day, this would be more efficiently done *manually*=20
> than with a `virtual` value system. That is, you do this:
>
> class B_base
> {
> public:
> virtual A& get_a() =3D 0;
> virtual const A& get_a() const =3D 0;
> };
>
> class B : public B_base
> {
> public:
> A a =3D 1;
>
> virtual A& get_a() override final {return a;}
> virtual const A& get_a() const override final {return a;}
> };
>
> class D : public B_base
> {
> public:
> virtual A& get_a() override {return a;}
> virtual const A& get_a() const override {return a;}
>
> C a =3D 3;
> };
>
> `B` is for standalone usage (which is why its overrides are `final`);=20
> `B_base` is what you use when you're deriving a class. And `B_base` is wh=
at=20
> most functions should take as arguments if they want polymorphism.
>
> So what is the motivation for your proposal? The above code is more=20
> efficient. So why would you not do it? Because you have to type `get_a` t=
o=20
> get at the variable?
>
--=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.
To view this discussion on the web visit https://groups.google.com/a/isocpp=
..org/d/msgid/std-proposals/94b23f30-9b24-40b2-b89c-6bdaf38c689e%40isocpp.or=
g.
------=_Part_34610_1702305938.1531893280232
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr">The value it provides is as high as the inheritances. This=
idea applies an inheritance with simultaneous classes. Solve many of the p=
roblems of coding interrelated classes, obviously I will not be collecting =
signatures or creating a community around this idea, it is just very useful=
and you must accept it. Nobody will come to complain about the impossibili=
ties, in fact I'm just seeing that many users prefer to move to another=
language than to improve C++.<br>As you apply the inheritance for some rea=
son, you need to apply the inheritance in multiple classes at the same time=
..<br><br>In this thread example I have never mentioned sizeof(). The values=
=E2=80=8B=E2=80=8Bset for the classes will be static after compilation, so=
a member class declared as virtual should not be reserved beyond the last =
class declared. Thus D will have as member (C+A), while B will have as a me=
mber only (A). In fact this feature uses less space than normal as opposed =
to (C+A,A).<br><br>I think you're confusing things. How are the data st=
acked?<br><br>Mira esto:<br>(gdb) print b<br>$1 =3D {a =3D {z =3D 1}}<br>(g=
db) print d<br>$2 =3D {<B> =3D {a =3D {z =3D 1}}, a =3D {<A> =
=3D {z =3D 3}, y =3D 3}}<br><br>By using 'virtual' on a variable yo=
u can simplify '<A> =3D {z =3D 3}' with 'a =3D {z =3D 1}&=
#39;, I do not know if I explain it, every time a call is made to the funct=
ion of class A is only covering the use of this data and no other, so you c=
an easily point to only one memory space.<br>And another thing, when callin=
g from any function from B/D to A/C, the A/C function forgets the data of B=
/D, it is not covering it.<br><br>=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D<br><br>El valor que pro=
porciona es tan alta como las herencias. Esta idea aplica una herencia con =
clases simultaneas. Resuelve muchos de los problemas de codificaci=C3=B3n d=
e clases interrelacionadas, obviamente no voy a estar juntando firmas o cre=
ando una comunidad alrededor de esta idea, simplemente es muy util y debes =
aceptarlo. Nadie te va a venir a quejarse de las imposibilidades, de hecho =
solo estoy viendo que muchos usuarios prefieren mudarse a otro lenguaje que=
mejorar C++.<br>Asi como aplicas la herencia por algun motivo, necesitas a=
plicar la herencia en multiples clases al mismo tiempo.<br><br>En este ejem=
plo del hilo nunca he mencionado a sizeof(). Los valores fijados para las c=
lases seran estaticos luego de la compilaci=C3=B3n, por lo que una clase mi=
embro declarada como virtual no deberia reservarse mas alla que en la ultim=
a clase declarada. Asi D tendra como miembro (C+A), mientras que B tendra c=
omo miembro solo (A). De hecho esta caracteristica usa menos espacio de lo =
normal al contrario de (C+A,A).<br><br>Creo que estas confundiendo las cosa=
s. Como se apilan los datos?<br><br>Mira esto:<br>(gdb) print b<br>$1 =3D {=
a =3D {z =3D 1}}<br>(gdb) print d<br>$2 =3D {<B> =3D {a =3D {z =3D 1}=
}, a =3D {<A> =3D {z =3D 3}, y =3D 3}}<br><br>Con utilizar 'virtu=
al' sobre una variable se puede simplificar '<A> =3D {z =3D 3=
}' con 'a =3D {z =3D 1}', no se si me explico, cada vez que se =
hace un llamado a la funcion de la clase A solo esta abarcando el uso a est=
os datos y a ningun otro, por lo que facilmente se puede apuntar a solo un =
espacio de memoria.<br>Y otra cosa, cuando se llama desde cualquier funcion=
de B/D a A/C, la funcion de A/C se olvida de los datos de B/D, no la esta =
abarcando.<br><br><br>El domingo, 15 de julio de 2018, 13:19:49 (UTC-3), Ni=
col Bolas escribi=C3=B3:<blockquote class=3D"gmail_quote" style=3D"margin: =
0;margin-left: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;"><div d=
ir=3D"ltr">On Sunday, July 15, 2018 at 2:25:44 AM UTC-4, <a>rmb...@gmail.co=
m</a> wrote:<blockquote class=3D"gmail_quote" style=3D"margin:0;margin-left=
:0.8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir=3D"ltr">This i=
s based on the other thread: <a href=3D"https://groups.google.com/a/isocpp.=
org/forum/#!topic/std-proposals/dSAu_sbyEXA" rel=3D"nofollow" target=3D"_bl=
ank" onmousedown=3D"this.href=3D'https://groups.google.com/a/isocpp.org=
/forum/#!topic/std-proposals/dSAu_sbyEXA';return true;" onclick=3D"this=
..href=3D'https://groups.google.com/a/isocpp.org/forum/#!topic/std-propo=
sals/dSAu_sbyEXA';return true;">https://groups.google.com/a/<wbr>isocpp=
..org/forum/#!topic/std-<wbr>proposals/dSAu_sbyEXA</a><br><br>I want to star=
t with this new thread with a more complete proposal, since I realize that =
you can not think for yourselves and much less study it.<br></div></blockqu=
ote><div><br></div><div>For what it's worth, nobody misunderstood your =
previous thread. We understood what you were asking for just fine. We get i=
t.</div><div><br></div><div>The solution simply does not provide enough val=
ue. The problem it purports to solve is not encountered by a significant nu=
mber of C++ coders. And the code examples you've provided as motivation=
represent coding styles that are incoherent or otherwise are things we wou=
ld rather people not be doing. That is, this problem is mainly encountered =
in badly designed systems; it's best to avoid bad design rather than to=
create a feature that allows it.<br></div><div><br></div><div>At the very =
least, your example of the problem is sufficiently abstract that the primar=
y question I have is "why are you writing your code that way? Why is D=
inheriting from these things? What is this saying about the relationships =
between these objects?" Providing an example culled from a real progra=
m would make for a more convincing argument than this hypothetical A/B/C/D =
example.</div><div><br></div><div>There are also implementation questions t=
o consider. Using your A/B/C/D example, how exactly does this work? This se=
ems like a virtual base class kind of thing, only with members.</div><div><=
br></div><div>So... what is `sizeof(B)`? That has to be a static value, fix=
ed at compile time. `B` obviously has a vtable pointer or whatever other ma=
chinery is needed to implement virtual functionality. But does `B` reserve =
sufficient space to store an `A` within it? Because if it does, then <i>eve=
ry</i> `B` must have that space. Even `D::B` still must have enough space t=
o store an `A`, even though `D::B::a` doesn't access that space.</div><=
div><br></div><div>That's not a good thing.</div><div><br></div><div>Fu=
rthermore, like virtual inheritance, the question of when `D::B::a` starts =
pointing to `D::a::A` starts becoming relevant. For example, with normal `v=
irtual` functions, in `B`'s constructor, calling virtual functions will=
only call overrides in `B`; if `D` overrode any virtuals from `B`, they wo=
uld not be called from `B`'s constructors.</div><div><br></div><div>Pre=
sumably, virtual members would work the same way. This reinforces the fact =
that `B` must always have sufficient storage for `B::a` within itself. Why?=
Because `B`'s constructor does not know that it was called as a base c=
lass. Therefore, it must initialize its member subobjects, so it will alway=
s initialize `B::a`. And it will never actually use it (unless someone uses=
`this->B::a`, just as with calling a specific virtual function).</div><=
div><br></div><div>So your `D` class will indeed have two `a` subobjects. I=
t's just that one of them is much more difficult to access.<br></div><d=
iv><br></div><div>At the end of the day, this would be more efficiently don=
e <i>manually</i> than with a `virtual` value system. That is, you do this:=
</div><div><br></div><div style=3D"background-color:rgb(250,250,250);border=
-color:rgb(187,187,187);border-style:solid;border-width:1px"><code><div><sp=
an style=3D"color:#008">class</span><span style=3D"color:#000"> B_base<br><=
/span><span style=3D"color:#660">{</span><span style=3D"color:#000"><br></s=
pan><span style=3D"color:#008">public</span><span style=3D"color:#660">:</s=
pan><span style=3D"color:#000"><br>=C2=A0 </span><span style=3D"color:#008"=
>virtual</span><span style=3D"color:#000"> A</span><span style=3D"color:#66=
0">&</span><span style=3D"color:#000"> get_a</span><span style=3D"color=
:#660">()</span><span style=3D"color:#000"> </span><span style=3D"color:#66=
0">=3D</span><span style=3D"color:#000"> </span><span style=3D"color:#066">=
0</span><span style=3D"color:#660">;</span><span style=3D"color:#000"><br>=
=C2=A0 </span><span style=3D"color:#008">virtual</span><span style=3D"color=
:#000"> </span><span style=3D"color:#008">const</span><span style=3D"color:=
#000"> A</span><span style=3D"color:#660">&</span><span style=3D"color:=
#000"> get_a</span><span style=3D"color:#660">()</span><span style=3D"color=
:#000"> </span><span style=3D"color:#008">const</span><span style=3D"color:=
#000"> </span><span style=3D"color:#660">=3D</span><span style=3D"color:#00=
0"> </span><span style=3D"color:#066">0</span><span style=3D"color:#660">;<=
/span><span style=3D"color:#000"><br></span><span style=3D"color:#660">};</=
span><span style=3D"color:#000"><br><br></span><span style=3D"color:#008">c=
lass</span><span style=3D"color:#000"> B </span><span style=3D"color:#660">=
:</span><span style=3D"color:#000"> </span><span style=3D"color:#008">publi=
c</span><span style=3D"color:#000"> B_base<br></span><span style=3D"color:#=
660">{</span><span style=3D"color:#000"><br></span><span style=3D"color:#00=
8">public</span><span style=3D"color:#660">:</span><span style=3D"color:#00=
0"><br>=C2=A0 A a </span><span style=3D"color:#660">=3D</span><span style=
=3D"color:#000"> </span><span style=3D"color:#066">1</span><span style=3D"c=
olor:#660">;</span><span style=3D"color:#000"><br><br>=C2=A0 </span><span s=
tyle=3D"color:#008">virtual</span><span style=3D"color:#000"> A</span><span=
style=3D"color:#660">&</span><span style=3D"color:#000"> get_a</span><=
span style=3D"color:#660">()</span><span style=3D"color:#000"> </span><span=
style=3D"color:#008">override</span><span style=3D"color:#000"> </span><sp=
an style=3D"color:#008">final</span><span style=3D"color:#000"> </span><spa=
n style=3D"color:#660">{</span><span style=3D"color:#008">return</span><spa=
n style=3D"color:#000"> a</span><span style=3D"color:#660">;}</span><span s=
tyle=3D"color:#000"><br>=C2=A0 </span><span style=3D"color:#008">virtual</s=
pan><span style=3D"color:#000"> </span><span style=3D"color:#008">const</sp=
an><span style=3D"color:#000"> A</span><span style=3D"color:#660">&</sp=
an><span style=3D"color:#000"> get_a</span><span style=3D"color:#660">()</s=
pan><span style=3D"color:#000"> </span><span style=3D"color:#008">const</sp=
an><span style=3D"color:#000"> </span><span style=3D"color:#008">override</=
span><span style=3D"color:#000"><code><span style=3D"color:#008"> final</sp=
an><span style=3D"color:#660"></span></code> </span><span style=3D"color:#6=
60">{</span><span style=3D"color:#008">return</span><span style=3D"color:#0=
00"> a</span><span style=3D"color:#660">;}</span><span style=3D"color:#000"=
><br></span><span style=3D"color:#660">};</span><span style=3D"color:#000">=
<br><br></span><span style=3D"color:#008">class</span><span style=3D"color:=
#000"> D </span><span style=3D"color:#660">:</span><span style=3D"color:#00=
0"> </span><span style=3D"color:#008">public</span><span style=3D"color:#00=
0"> B_base<br></span><span style=3D"color:#660">{</span><span style=3D"colo=
r:#000"><br></span><span style=3D"color:#008">public</span><span style=3D"c=
olor:#660">:</span><span style=3D"color:#000"><br>=C2=A0 </span><span style=
=3D"color:#008">virtual</span><span style=3D"color:#000"> A</span><span sty=
le=3D"color:#660">&</span><span style=3D"color:#000"> get_a</span><span=
style=3D"color:#660">()</span><span style=3D"color:#000"> </span><span sty=
le=3D"color:#008">override</span><span style=3D"color:#000"> </span><span s=
tyle=3D"color:#660">{</span><span style=3D"color:#008">return</span><span s=
tyle=3D"color:#000"> a</span><span style=3D"color:#660">;}</span><span styl=
e=3D"color:#000"><br>=C2=A0 </span><span style=3D"color:#008">virtual</span=
><span style=3D"color:#000"> </span><span style=3D"color:#008">const</span>=
<span style=3D"color:#000"> A</span><span style=3D"color:#660">&</span>=
<span style=3D"color:#000"> get_a</span><span style=3D"color:#660">()</span=
><span style=3D"color:#000"> </span><span style=3D"color:#008">const</span>=
<span style=3D"color:#000"> </span><span style=3D"color:#008">override</spa=
n><span style=3D"color:#000"> </span><span style=3D"color:#660">{</span><sp=
an style=3D"color:#008">return</span><span style=3D"color:#000"> a</span><s=
pan style=3D"color:#660">;}</span><span style=3D"color:#000"><br><br>=C2=A0=
C a </span><span style=3D"color:#660">=3D</span><span style=3D"color:#000"=
> </span><span style=3D"color:#066">3</span><span style=3D"color:#660">;</s=
pan><span style=3D"color:#000"><br></span><span style=3D"color:#660">};</sp=
an></div></code></div><div><div><br></div><div>`B` is for standalone usage =
(which is why its overrides are `final`); `B_base` is what you use when you=
're deriving a class. And `B_base` is what most functions should take a=
s arguments if they want polymorphism.</div><div><br></div><div>So what is =
the motivation for your proposal? The above code is more efficient. So why =
would you not do it? Because you have to type `get_a` to get at the variabl=
e?<br></div></div></div></blockquote></div>
<p></p>
-- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals" group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<br />
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/94b23f30-9b24-40b2-b89c-6bdaf38c689e%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/94b23f30-9b24-40b2-b89c-6bdaf38c689e=
%40isocpp.org</a>.<br />
------=_Part_34610_1702305938.1531893280232--
------=_Part_34609_1171648708.1531893280231--
.