Questions tagged [this]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
12
votes
1answer
703 views

Why was “self” chosen over “this” for the name of the first parameter of python methods?

What was the rationale for choosing the name self instead of this when defining class methods in Python? Yes, of course, you can name it whatever you want - but the widely agreed-upon name for the ...
0
votes
1answer
131 views

Does passing this as argument potentially cause exposure of invalid object state?

This question is based on two premises: First: an object must always have valid state. It is discussed in various posts, too. https://stackoverflow.com/questions/22408804/should-a-c-object-always-be-...
-3
votes
1answer
3k views

Is it possible for $this to return a __construct?

I am currently working on my PHP skills and at the moment I'm working with classes. What I want to do is to create a class for which I can echo the object. I have the following example: class ...
2
votes
2answers
247 views

Avoid This Pointer

PROBLEM: this points to different instances at different stages of execution (as it should). But it is not always obvious which instance is that. On the other hand we could minimize the use of this, ...
-10
votes
1answer
9k views

Using delete this to free memory in class

Whenever we are writing destructors in C++ (though this concept could apply in other languages) could we just not write delete this; and it would delete whatever data is inside of the class? Is this ...
1
vote
2answers
499 views

C: “this” vs “<instance name>”

I'm using C in a minimal, efficient OOP style to build a game engine. A problem I've begun to face as the engine code settles is my (erstwhile) choice to use this. For example, I have: void ...
3
votes
3answers
1k views

Why is C++ “this” poorly designed?

For every a and b which are non-const pointers of the same type, you can do a = b;, right? Inside non-const member functions the this keyword exists, which is a non-const pointer. So logicaly if b is ...