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.
Best Answer
Using the word object in the reference is redundant.
Perhaps caller and callee is simplistic enough. Referring to the actual object as an instance of type is also another approach as noted by Wyatt; instance of Puppy or if being succinct is the goal...instance.