Questions tagged [this]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
2 votes
1 answer

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,...
tweekz's user avatar
  • 227
14 votes
1 answer

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 ...
Qix - MONICA WAS MISTREATED's user avatar
0 votes
1 answer

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.
user2180613's user avatar
  • 1,782
-3 votes
1 answer

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 ...
Alex Luigi's user avatar
2 votes
2 answers

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, ...
Zon's user avatar
  • 187
-11 votes
1 answer

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 ...
bkeys's user avatar
  • 1
1 vote
2 answers

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 ...
Engineer's user avatar
  • 767
4 votes
3 answers

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 ...
user3123061's user avatar
  • 1,607