James Kanze said:
[...]
In practice, as someone else has pointed out in this thread, you
can take the address of a non-static member function, with or
without the presense of an object. Which seems like
a conclusive argument that whatever non-static member functions
might be, and whether they exist or not, their reality or status
or whatever is independent of any object.
I have pointed this out , but I aslo pointed out this would
not be standard complaint. I disagree with your analysis,
I think the standard defines a rule that means a function
cannot exists without an object, the opposite of your
conclusion.
So what am I taking the address of, when I take its address.
You are in a gray area where you have a pointer to a functions definition,
but you can't invoke the function, so does the function exist?
Given something like:
struct Toto
{
void titi();
};
int
main()
{
void (Toto::*pmf1)() = &Toto::titi;
// What does pmf1 point to, if Toto::titi
// doesn't exit?
Its the address InstrPointer will point to when the the function is
invoked.( for an assumed machine architecture).
&Toto::titi is the location where the function is defined.
Toto* p1 = new Toto;
Toto* p2 = new Toto;
void (Toto::*pmf2)() = &Toto::titi;
// And what about here, since according to
// your logic, there are now two Toto::titi?
No there are two pointers.
Toto::titi is part of the class/object-type defiition, there is only one
definiton for all instances of this class/object-type.
(whether this is guaranteed to be the case on all implementations, I think
is undefined).
Note: I am not talking about breaking the one definition rule , I am
thinking of possible implementations of virtual functions.
}
No matter how you cut it: if existance has any meaning for
a member function, it exists for the entire time the program
runs, regardless of the presence or absence of instances.
If you are going to give a function a lifetime then consider a function as a
sub-process. What is the lifetime of that sub-process?
It seems stupid to speak about the lifetime of a function, where every
function has the same lifetime(that of program execution).
What does your argumentation have to do with the rules of the
C++ language? It's purely a lexical dispute.
The rules suggest that a NSMF cannot be called unless called on an object.
This supports my argument that C++ supports the OOP concept that NSMF's are
members of an object.
If you are suggesting C++ does not support OOP, this seems like a pretty
bold statement to make considering the overwhelming evidence to suggest
otherwise. I don't see how you can brush this of as 'purely lexical'.
Except that you can't find anyone speaking differently, at least
where C++ is concerned.
No I can find hundreds of quotes to support me, the fact that nobody in here
seems to be speaking up against the majority(in here) doesn't mean you are
the real majority.
In the case of the STL argument, I've argued consistently that
the term is ambiguous. Unlike the current discussion, there is
no consensus among C++ practitionners as to what STL means. In
some ways, this is regretable, but neither I nor anyone else can
force consensus. (Luckily, in the case of the meaning of STL,
the distinction isn't really important.)
You and a few other in here have claimed that a NSMF is a member of a class
but not an object.
You have given no evidence at all to support your claim except for the fact
that you are in the majority therefore you are correct.
C++ is a language where the class is the definition of an object, so to say
something is a member of a class but not part of an object doesn't make
sense, bar the exception of static members.
Member functions as part of an object are a well defined OOP concept and if
a language doesn't support this, it cannot be said to support OOP. However
C++ does support OOP so therefore it follows that C++ supports the concept
of member functions as members of an object. The argument you have put
forward is very non supportive of OOP, and if your argument was correct it
would mean C++ did not support OOP.
Can you at least agree that a language must support this concept to support
OOP?