F
Fabrizio J Bonsignore
What is the point of OOP and C++, anyway? I want to write ... AO
Function(); ... AO x = Function(); I want some NEW x object of type AO
in its relevant scope to CATCH the AO object returned from function
Function(); copy it and become IT. I do NOT want to have a previous AO
object initialized in default values, AO x; THEN an assignment
operator called on it with Function(); [like in x.this-
x become initialized with the returned old value from Function(). It
happens that AO is a very complex abstraction of the world and
Function() returns a lengthy user process construct with lots of
values obtained from different sources and under different conditions
with lots of very processed and prepared fields and I want to further
process them in another scope in the application, so going through TWO
initializations, default constructor and assignment operator is just
overkill! I cannot simply copy bitwise because AO has the objective of
managing memory, ascertain an object is unique, store memory, and has
side effects like filling in GUI lists and painting in memory stecils
and... I understand that the object returned by **value** from
Function() is a temporary and anonymous memory address that will go
away at any moment out of my control, so I cannot take addresses and
modifying the calling argument in another function makes no sense (in
the absence of side effects) so const is not really necessary nor an
issue, BUT, I need to hold on to the memory of THAT complex instance
and that is the meaning of x! The copy constructor knows what to do
with its own class of objects, it knows what fields are just copied,
which ones initialized from default, which ones need CLONING(), which
ones require new memory before copying them, what complex lot of
processes to place under the rug and take out of the way so that the
user code looks clean and readable and maintainable, etc. But the
compiler is complaining if the copy constructor is programmed
explicitly! It does not accept both assignment operator= and explicit
copy constructor (EXPLICIT means EXPLICITLY PROGRAMMED, not a
hypothetical redundant keyword when implicit means not even mentioned
because bitwise copy is done automatically). I already tried several
combinations: the g++ compiler gets confsed with an illegal AO::AO(AO)
constructor signature! It does not accept BOTH assignment and copy
methods. I can workaround with idiot, I mean, idiom, AO(AO *);
[pointer argument copy constructor] and AO x = &Function(); [address
of temporary!], but it is NOT the C++ I knew for a decade+! Should be
simple and obvious that the returned temporary value has to subsist
til at LEAST the end of this (next) statement! Or function return
values become impossible! Which IS the point of OOP anyway: to handle
data as bundles along its methods and forget about details so complex
data can be handled as easily as arithmetic numbers. But NO! The
compiler is broken, and worse, I cannot see when it happened nor am
really sure it is not some hidden flag, make idiosincracy, weird name
clash, memory corruption, unwanted update or what (at least NOT
without wasting a lot of time like writing this complaint). I ve been
reading other people s call for help on the same problem and the
replies miss the issue, or the case is not exactly the same. Neither
explicit nor const affect the issue: the issue is the compiler looking
for illegal AO::AO(AO) and complaining for legal AO::AO(AO&) methods.
Similar problem with operator=(AO... both as pass-by-reference and
pass-by-value. The best documentation of a system is ALWAYS the system
itself! And its own standard, so any other written standard is just
ideal reality in the future and a goal to achieve IF at all possible!
Version I used is g++ 3.4.2. It was working and got broken, but I want
it to work in THIS project as is. I need a solution or a technical
explanation of why the compiler parser is complaining about looking
for AO::AO(AO) when it also says it is illegal when TO ALL MEANS
AO::AO(AO &) is TOTALLY equivalent and even stronger (should have
preference), and why it complaints if BOTH assignment= and copy
constructor methods are EXPLICITLY DEFINED (programmed). Changing to a
new version is not the best solution... there may be other issues and
so far no known bug has had an impact in this code, so if it is not
broken, do not fix it! But fix this problem, please. (BTW, mofeel.net
means in SPANISH: ...mocked the web).
Danilo J Bonsignore
Function(); ... AO x = Function(); I want some NEW x object of type AO
in its relevant scope to CATCH the AO object returned from function
Function(); copy it and become IT. I do NOT want to have a previous AO
object initialized in default values, AO x; THEN an assignment
operator called on it with Function(); [like in x.this-
a COPY CONSTRUCTOR to be invoked under MY control, to make the NEW AOoperator=(Function())] because it is a double initialization! I want
x become initialized with the returned old value from Function(). It
happens that AO is a very complex abstraction of the world and
Function() returns a lengthy user process construct with lots of
values obtained from different sources and under different conditions
with lots of very processed and prepared fields and I want to further
process them in another scope in the application, so going through TWO
initializations, default constructor and assignment operator is just
overkill! I cannot simply copy bitwise because AO has the objective of
managing memory, ascertain an object is unique, store memory, and has
side effects like filling in GUI lists and painting in memory stecils
and... I understand that the object returned by **value** from
Function() is a temporary and anonymous memory address that will go
away at any moment out of my control, so I cannot take addresses and
modifying the calling argument in another function makes no sense (in
the absence of side effects) so const is not really necessary nor an
issue, BUT, I need to hold on to the memory of THAT complex instance
and that is the meaning of x! The copy constructor knows what to do
with its own class of objects, it knows what fields are just copied,
which ones initialized from default, which ones need CLONING(), which
ones require new memory before copying them, what complex lot of
processes to place under the rug and take out of the way so that the
user code looks clean and readable and maintainable, etc. But the
compiler is complaining if the copy constructor is programmed
explicitly! It does not accept both assignment operator= and explicit
copy constructor (EXPLICIT means EXPLICITLY PROGRAMMED, not a
hypothetical redundant keyword when implicit means not even mentioned
because bitwise copy is done automatically). I already tried several
combinations: the g++ compiler gets confsed with an illegal AO::AO(AO)
constructor signature! It does not accept BOTH assignment and copy
methods. I can workaround with idiot, I mean, idiom, AO(AO *);
[pointer argument copy constructor] and AO x = &Function(); [address
of temporary!], but it is NOT the C++ I knew for a decade+! Should be
simple and obvious that the returned temporary value has to subsist
til at LEAST the end of this (next) statement! Or function return
values become impossible! Which IS the point of OOP anyway: to handle
data as bundles along its methods and forget about details so complex
data can be handled as easily as arithmetic numbers. But NO! The
compiler is broken, and worse, I cannot see when it happened nor am
really sure it is not some hidden flag, make idiosincracy, weird name
clash, memory corruption, unwanted update or what (at least NOT
without wasting a lot of time like writing this complaint). I ve been
reading other people s call for help on the same problem and the
replies miss the issue, or the case is not exactly the same. Neither
explicit nor const affect the issue: the issue is the compiler looking
for illegal AO::AO(AO) and complaining for legal AO::AO(AO&) methods.
Similar problem with operator=(AO... both as pass-by-reference and
pass-by-value. The best documentation of a system is ALWAYS the system
itself! And its own standard, so any other written standard is just
ideal reality in the future and a goal to achieve IF at all possible!
Version I used is g++ 3.4.2. It was working and got broken, but I want
it to work in THIS project as is. I need a solution or a technical
explanation of why the compiler parser is complaining about looking
for AO::AO(AO) when it also says it is illegal when TO ALL MEANS
AO::AO(AO &) is TOTALLY equivalent and even stronger (should have
preference), and why it complaints if BOTH assignment= and copy
constructor methods are EXPLICITLY DEFINED (programmed). Changing to a
new version is not the best solution... there may be other issues and
so far no known bug has had an impact in this code, so if it is not
broken, do not fix it! But fix this problem, please. (BTW, mofeel.net
means in SPANISH: ...mocked the web).
Danilo J Bonsignore