What's the left-hand side of a method invocation called?

83 views Asked by At

Given the following line

cat.meow(10, x);
  • "meow" is the "function" or "method" being called
  • 10 is the "first argument"
  • x is the "second argument"

What is cat called?

I'm dissatisfied with the answer, cat is called "the object". I want to say I've heard it called the "receiver", but I don't remember where I've heard that.

Considering both 10 and x can be objects, calling cat "the object" doesn't help me distinguish this component from the argument components.

This makes it difficult to discuss the various components that makeup a function call.

3

There are 3 answers

0
Aadit M Shah On BEST ANSWER

It is called the “subject” following the subject-verb-object sentence structure that object-oriented programming mimics:

cat.meow(10, x);
|_||___||_____|
 |   |     |
 |   |     +--> object (the arguments list is a tuple object)
 |   |
 |   +--> verb (the verb is the method name with the dot)
 |
 +--> subject (quite self explanatory)

I should clarify that I call it the “subject” because it makes sense to me. However, there's no consensus on this nomenclature. Everyone has their own opinions on what it should be called.

0
JulienD On

An object is an instance of a specific class. You can use it to say cat is an instance of class [put class name here], just like 10 is an instance of Integer.

0
Amal Ts On

Normally we call that object. According to your logic, take it in this way

meow(self,10, x) - This is the actual function where self is an object like 10 and x

Same in this case - cat.meow(10,x)