Questions tagged [this]
The this tag has no summary.
8 questions
2
votes
1
answer
195
views
How is $this provided in PHP?
I got a fundamental question about the $this keyword in PHP and how it is defined. Pracitcally, I know what it is and what it does. But I am interested in how it is provided / implemented?
For example,...
14
votes
1
answer
971
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
1
answer
163
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
1
answer
4k
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
2
answers
276
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, ...
-11
votes
1
answer
10k
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
2
answers
537
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 ...
4
votes
3
answers
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 ...