Let's suppose you've got a class defined (in pseudocode):
class Puppy {
// ...
string sound = "Rawr!";
void bark() {
print(sound);
}
}
And say, given a Puppy
instance, you call it's bark()
method:
int main() {
Puppy p;
p.bark();
}
Notice how bark()
uses the member variable sound
. In many contexts, I've seen folks describe sound
as the member variable of the "calling object."
My question is, what's a better term to use than "calling object"?
To me, the object is not doing any calling. We know that member functions are in a way just functions with an implicit this
or self
parameter.
I've come up with "receiving object" or "message recipient" which makes sense if you're down with the "messaging" paradigm.
Do any of you happy hackers have a term that you like to use?
I feel it should mean "the object upon which a method is called" and TOUWAMIC just doesn't cut it.
As for who the "caller" is, I would say that main
instantiates a Puppy
object and calls its bark()
method.
p
was called or that the callee was called. Objects are never "called" nor do they "call" per se.main()
. Since your title question asks for a name for the "calling object", it's interesting that you chose to callp.bark()
from a function that doesn't belong to any class. Given that, could you restate your question so that we can figure out what you're really asking about?