Mulan
Mulan

Reputation: 135257

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

Given the following line

cat.meow(10, x);

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.

Upvotes: 0

Views: 86

Answers (3)

Aadit M Shah
Aadit M Shah

Reputation: 74204

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.

Upvotes: 2

Amal Ts
Amal Ts

Reputation: 861

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)

Upvotes: 0

JulienD
JulienD

Reputation: 7293

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.

Upvotes: 1

Related Questions