<s>
this	O
,	O
self	B-Operating_System
,	O
and	O
Me	O
are	O
keywords	O
used	O
in	O
some	O
computer	O
programming	O
languages	O
to	O
refer	O
to	O
the	O
object	O
,	O
class	O
,	O
or	O
other	O
entity	O
of	O
which	O
the	O
currently	O
running	O
code	O
is	O
a	O
part	O
.	O
</s>
<s>
The	O
entity	O
referred	O
to	O
by	O
these	O
keywords	O
thus	O
depends	O
on	O
the	O
execution	O
context	O
(	O
such	O
as	O
which	O
object	O
is	O
having	O
its	O
method	B-Language
called	O
)	O
.	O
</s>
<s>
In	O
many	O
object-oriented	B-Language
programming	I-Language
languages	I-Language
,	O
this	O
(	O
also	O
called	O
self	B-Operating_System
or	O
Me	O
)	O
is	O
a	O
variable	O
that	O
is	O
used	O
in	O
instance	B-Language
methods	I-Language
to	O
refer	O
to	O
the	O
object	O
on	O
which	O
they	O
are	O
working	O
.	O
</s>
<s>
The	O
first	O
OO	O
language	O
,	O
SIMULA	B-Language
67	I-Language
,	O
used	O
this	O
to	O
explicitly	O
reference	B-Language
the	O
local	O
object	O
.	O
</s>
<s>
C++	B-Language
and	O
languages	O
which	O
derive	O
in	O
style	O
from	O
it	O
(	O
such	O
as	O
Java	B-Language
,	O
C#	B-Application
,	O
D	B-Application
,	O
and	O
PHP	B-Application
)	O
also	O
generally	O
use	O
this	O
.	O
</s>
<s>
Smalltalk	B-Application
and	O
others	O
,	O
such	O
as	O
Object	B-Language
Pascal	I-Language
,	O
Perl	B-Language
,	O
Python	B-Language
,	O
Ruby	B-Language
,	O
Rust	B-Application
,	O
Objective-C	B-Language
,	O
DataFlex	B-Application
and	O
Swift	B-Application
,	O
use	O
self	B-Operating_System
.	O
</s>
<s>
Microsoft	O
's	O
Visual	B-Language
Basic	I-Language
uses	O
Me	O
.	O
</s>
<s>
The	O
concept	O
is	O
similar	O
in	O
all	O
languages	O
:	O
this	O
is	O
usually	O
an	O
immutable	O
reference	B-Language
or	O
pointer	O
which	O
refers	O
to	O
the	O
current	O
object	O
;	O
the	O
current	O
object	O
often	O
being	O
the	O
code	O
that	O
acts	O
as	O
'	O
parent	O
 '	O
or	O
'	O
invocant	O
 '	O
to	O
the	O
property	B-Language
,	O
method	B-Language
,	O
sub-routine	O
or	O
function	O
that	O
contains	O
the	O
this	O
keyword	O
.	O
</s>
<s>
After	O
an	O
object	O
is	O
properly	O
constructed	O
,	O
or	O
instantiated	O
,	O
this	O
is	O
always	O
a	O
valid	O
reference	B-Language
.	O
</s>
<s>
Or	O
alternatively	O
,	O
the	O
current	O
object	O
referred	O
to	O
by	O
this	O
may	O
be	O
an	O
independent	O
code	O
object	O
that	O
has	O
called	O
the	O
function	O
or	O
method	B-Language
containing	O
the	O
keyword	O
this	O
.	O
</s>
<s>
Such	O
a	O
thing	O
happens	O
,	O
for	O
example	O
,	O
when	O
a	O
JavaScript	B-Language
event	O
handler	O
attached	O
to	O
an	O
HTML	O
tag	O
in	O
a	O
web	O
page	O
calls	O
a	O
function	O
containing	O
the	O
keyword	O
this	O
stored	O
in	O
the	O
global	O
space	O
outside	O
the	O
document	O
object	O
;	O
in	O
that	O
context	O
,	O
this	O
will	O
refer	O
to	O
the	O
page	O
element	O
within	O
the	O
document	O
object	O
,	O
not	O
the	O
enclosing	O
window	O
object	O
.	O
</s>
<s>
In	O
some	O
languages	O
,	O
for	O
example	O
C++	B-Language
,	O
Java	B-Language
,	O
and	O
Raku	O
this	O
or	O
self	B-Operating_System
is	O
a	O
keyword	O
,	O
and	O
the	O
variable	O
automatically	O
exists	O
in	O
instance	B-Language
methods	I-Language
.	O
</s>
<s>
In	O
others	O
,	O
for	O
example	O
Python	B-Language
,	O
Rust	B-Application
,	O
and	O
Perl	B-Language
5	O
,	O
the	O
first	O
parameter	O
of	O
an	O
instance	B-Language
method	I-Language
is	O
such	O
a	O
reference	B-Language
.	O
</s>
<s>
In	O
Python	B-Language
and	O
Perl	B-Language
,	O
the	O
parameter	O
need	O
not	O
necessarily	O
be	O
named	O
this	O
or	O
self	B-Operating_System
;	O
it	O
can	O
be	O
named	O
freely	O
by	O
the	O
programmer	O
like	O
any	O
other	O
parameter	O
.	O
</s>
<s>
However	O
,	O
by	O
informal	O
convention	O
,	O
the	O
first	O
parameter	O
of	O
an	O
instance	B-Language
method	I-Language
in	O
Perl	B-Language
or	O
Python	B-Language
is	O
named	O
self	B-Operating_System
.	O
</s>
<s>
Rust	B-Application
requires	O
the	O
self	B-Operating_System
object	O
to	O
be	O
called	O
&	O
self	B-Operating_System
or	O
self	B-Operating_System
,	O
depending	O
on	O
whether	O
the	O
invoked	O
function	O
borrows	O
the	O
invocant	O
,	O
or	O
moves	O
it	O
in	O
,	O
respectively	O
.	O
</s>
<s>
Static	B-Language
methods	I-Language
in	O
C++	B-Language
or	O
Java	B-Language
are	O
not	O
associated	O
with	O
instances	O
but	O
classes	O
,	O
and	O
so	O
cannot	O
use	O
this	O
,	O
because	O
there	O
is	O
no	O
object	O
.	O
</s>
<s>
In	O
other	O
languages	O
,	O
such	O
as	O
Ruby	B-Language
,	O
Smalltalk	B-Application
,	O
Objective-C	B-Language
,	O
or	O
Swift	B-Application
,	O
the	O
method	B-Language
is	O
associated	O
with	O
a	O
class	O
object	O
that	O
is	O
passed	O
as	O
this	O
,	O
and	O
they	O
are	O
called	O
class	B-Application
methods	I-Application
.	O
</s>
<s>
For	O
class	B-Application
methods	I-Application
,	O
Python	B-Language
uses	O
cls	O
to	O
access	O
to	O
the	O
class	O
object	O
.	O
</s>
<s>
When	O
lexical	O
scoping	O
is	O
used	O
to	O
infer	O
this	O
,	O
the	O
use	O
of	O
this	O
in	O
code	O
,	O
while	O
not	O
illegal	O
,	O
may	O
raise	O
warning	O
bells	O
to	O
a	O
maintenance	O
programmer	O
,	O
although	O
there	O
are	O
still	O
legitimate	O
uses	O
of	O
this	O
in	O
this	O
case	O
,	O
such	O
as	O
referring	O
to	O
instance	O
variables	O
hidden	O
by	O
local	O
variables	O
of	O
the	O
same	O
name	O
,	O
or	O
if	O
the	O
method	B-Language
wants	O
to	O
return	O
a	O
reference	B-Language
to	O
the	O
current	O
object	O
,	O
i.e.	O
</s>
<s>
In	O
some	O
compilers	O
(	O
for	O
example	O
GCC	B-Application
)	O
,	O
pointers	O
to	O
C++	B-Language
instance	B-Language
methods	I-Language
can	O
be	O
directly	O
cast	O
to	O
a	O
pointer	O
of	O
another	O
type	O
,	O
with	O
an	O
explicit	O
this	B-Application
pointer	I-Application
parameter	O
.	O
</s>
<s>
The	O
dispatch	O
semantics	O
of	O
this	O
,	O
namely	O
that	O
method	B-Language
calls	I-Language
on	O
this	O
are	O
dynamically	O
dispatched	O
,	O
is	O
known	O
as	O
open	O
recursion	O
,	O
and	O
means	O
that	O
these	O
methods	O
can	O
be	O
overridden	B-Language
by	O
derived	O
classes	O
or	O
objects	O
.	O
</s>
<s>
By	O
contrast	O
,	O
direct	O
named	O
recursion	O
or	O
anonymous	B-Language
recursion	I-Language
of	O
a	O
function	O
uses	O
closed	O
recursion	O
,	O
with	O
early	O
binding	O
.	O
</s>
<s>
For	O
example	O
,	O
in	O
the	O
following	O
Perl	B-Language
code	O
for	O
the	O
factorial	O
,	O
the	O
token	O
__SUB__	O
is	O
a	O
reference	B-Language
to	O
the	O
current	O
function	O
:	O
</s>
<s>
By	O
contrast	O
,	O
in	O
C++	B-Language
(	O
using	O
an	O
explicit	O
this	O
for	O
clarity	O
,	O
though	O
not	O
necessary	O
)	O
the	O
this	O
binds	O
to	O
the	O
object	O
itself	O
,	O
but	O
if	O
the	O
class	B-Application
method	I-Application
was	O
declared	O
"	O
virtual	O
"	O
i.e.	O
</s>
<s>
polymorphic	O
in	O
the	O
base	O
,	O
it	O
's	O
resolved	O
via	O
dynamic	O
dispatch	O
(	O
late	O
binding	O
)	O
so	O
that	O
derived	O
classes	O
can	O
override	B-Language
it	O
.	O
</s>
<s>
This	O
example	O
is	O
artificial	O
,	O
since	O
this	O
is	O
direct	O
recursion	O
,	O
so	O
overriding	B-Language
the	O
factorial	O
method	B-Language
would	O
override	B-Language
this	O
function	O
;	O
more	O
natural	O
examples	O
are	O
when	O
a	O
method	B-Language
in	O
a	O
derived	O
class	O
calls	O
the	O
same	O
method	B-Language
in	O
a	O
base	O
class	O
,	O
or	O
in	O
cases	O
of	O
mutual	O
recursion	O
.	O
</s>
<s>
The	O
fragile	B-Application
base	I-Application
class	I-Application
problem	I-Application
has	O
been	O
blamed	O
on	O
open	O
recursion	O
,	O
with	O
the	O
suggestion	O
that	O
invoking	O
methods	O
on	O
this	O
default	O
to	O
closed	O
recursion	O
(	O
static	O
dispatch	O
,	O
early	O
binding	O
)	O
rather	O
than	O
open	O
recursion	O
(	O
dynamic	O
dispatch	O
,	O
late	O
binding	O
)	O
,	O
only	O
using	O
open	O
recursion	O
when	O
it	O
is	O
specifically	O
requested	O
;	O
external	O
calls	O
(	O
not	O
using	O
this	O
)	O
would	O
be	O
dynamically	O
dispatched	O
as	O
usual	O
.	O
</s>
<s>
The	O
way	O
this	O
is	O
solved	O
in	O
practice	O
in	O
the	O
JDK	O
is	O
through	O
a	O
certain	O
programmer	O
discipline	O
;	O
this	O
discipline	O
has	O
been	O
formalized	O
by	O
C	O
.	O
Ruby	B-Language
and	O
G	O
.	O
T	O
.	O
Leavens	O
;	O
it	O
basically	O
consists	O
of	O
the	O
following	O
rules	O
:	O
</s>
<s>
Code	O
that	O
can	O
be	O
reused	O
internally	O
(	O
by	O
invocation	O
from	O
other	O
methods	O
of	O
the	O
same	O
class	O
)	O
is	O
encapsulated	O
in	O
a	O
protected	O
or	O
private	O
method	B-Language
;	O
if	O
it	O
needs	O
to	O
be	O
exposed	O
directly	O
to	O
the	O
users	O
as	O
well	O
,	O
then	O
a	O
wrapper	O
public	O
method	B-Language
calls	I-Language
the	O
internal	O
method	B-Language
.	O
</s>
<s>
The	O
previous	O
recommendation	O
can	O
be	O
relaxed	O
for	O
pure	B-Application
methods	O
.	O
</s>
<s>
Early	O
versions	O
of	O
C++	B-Language
would	O
let	O
the	O
this	B-Application
pointer	I-Application
be	O
changed	O
;	O
by	O
doing	O
so	O
a	O
programmer	O
could	O
change	O
which	O
object	O
a	O
method	B-Language
was	O
working	O
on	O
.	O
</s>
<s>
This	O
feature	O
was	O
eventually	O
removed	O
,	O
and	O
now	O
this	O
in	O
C++	B-Language
is	O
an	O
r-value	O
.	O
</s>
<s>
Early	O
versions	O
of	O
C++	B-Language
did	O
not	O
include	O
references	O
and	O
it	O
has	O
been	O
suggested	O
that	O
had	O
they	O
been	O
so	O
in	O
C++	B-Language
from	O
the	O
beginning	O
,	O
this	O
would	O
have	O
been	O
a	O
reference	B-Language
,	O
not	O
a	O
pointer	O
.	O
</s>
<s>
C++	B-Language
lets	O
objects	O
destroy	O
themselves	O
with	O
the	O
source	O
code	O
statement	O
:	O
delete	O
this	O
.	O
</s>
<s>
The	O
keyword	O
this	O
in	O
C#	B-Application
works	O
the	O
same	O
way	O
as	O
in	O
Java	B-Language
,	O
for	O
reference	B-Language
types	I-Language
.	O
</s>
<s>
However	O
,	O
within	O
C#	B-Application
value	O
types	O
,	O
this	O
has	O
quite	O
different	O
semantics	O
,	O
being	O
similar	O
to	O
an	O
ordinary	O
mutable	O
variable	O
reference	B-Language
,	O
and	O
can	O
even	O
occur	O
on	O
the	O
left	O
side	O
of	O
an	O
assignment	O
.	O
</s>
<s>
One	O
use	O
of	O
this	O
in	O
C#	B-Application
is	O
to	O
allow	O
reference	B-Language
to	O
an	O
outer	O
field	O
variable	O
within	O
a	O
method	B-Language
that	O
contains	O
a	O
local	O
variable	O
that	O
has	O
the	O
same	O
name	O
.	O
</s>
<s>
In	O
such	O
a	O
situation	O
,	O
for	O
example	O
,	O
the	O
statement	O
var	O
n	O
=	O
localAndFieldname	O
;	O
within	O
the	O
method	B-Language
will	O
assign	O
the	O
type	O
and	O
value	O
of	O
the	O
local	O
variable	O
localAndFieldname	O
to	O
n	O
,	O
whereas	O
the	O
statement	O
var	O
n	O
=	O
this.localAndFieldname	O
;	O
will	O
assign	O
the	O
type	O
and	O
value	O
of	O
the	O
outer	O
field	O
variable	O
to	O
n	O
.	O
</s>
<s>
In	O
D	B-Application
this	O
in	O
a	O
class	O
,	O
struct	B-Application
or	O
union	O
method	B-Language
refers	O
to	O
an	O
immutable	O
reference	B-Language
of	O
the	O
instance	O
of	O
the	O
enclosing	O
aggregate	O
.	O
</s>
<s>
Classes	O
are	O
reference	B-Language
types	I-Language
,	O
structs	B-Application
and	O
unions	O
are	O
value	O
types	O
.	O
</s>
<s>
In	O
the	O
first	O
version	O
of	O
D	B-Application
,	O
the	O
keyword	O
this	O
is	O
used	O
as	O
a	O
pointer	O
to	O
the	O
instance	O
of	O
the	O
object	O
the	O
method	B-Language
is	O
bound	O
to	O
,	O
while	O
in	O
D2	O
it	O
has	O
the	O
character	O
of	O
an	O
implicit	O
ref	O
function	O
argument	O
.	O
</s>
<s>
In	O
the	O
programming	O
language	O
Dylan	B-Language
,	O
which	O
is	O
an	O
object-oriented	B-Language
language	I-Language
that	O
supports	O
multimethods	O
and	O
does	O
n't	O
have	O
a	O
concept	O
of	O
this	O
,	O
sending	O
a	O
message	O
to	O
an	O
object	O
is	O
still	O
kept	O
in	O
the	O
syntax	O
.	O
</s>
<s>
Within	O
features	O
(	O
routines	O
,	O
commands	O
and	O
queries	O
)	O
of	O
a	O
class	O
,	O
one	O
may	O
use	O
the	O
keyword	O
Current	O
to	O
reference	B-Language
the	O
current	O
class	O
and	O
its	O
features	O
.	O
</s>
<s>
Line	O
#10	O
(	O
above	O
)	O
has	O
the	O
implied	O
reference	B-Language
to	O
Current	O
by	O
the	O
call	O
to	O
simple	O
`foo	O
 '	O
.	O
</s>
<s>
Line	O
#10	O
(	O
below	O
)	O
has	O
the	O
explicit	O
reference	B-Language
to	O
Current	O
by	O
the	O
call	O
to	O
`	O
Current.foo	O
'	O
.	O
</s>
<s>
The	O
keyword	O
this	O
is	O
a	O
Java	B-Language
language	I-Language
keyword	O
that	O
represents	O
the	O
current	O
instance	O
of	O
the	O
class	O
in	O
which	O
it	O
appears	O
.	O
</s>
<s>
Since	O
all	O
instance	B-Language
methods	I-Language
are	O
virtual	O
in	O
Java	B-Language
,	O
this	O
can	O
never	O
be	O
null	O
.	O
</s>
<s>
In	O
JavaScript	B-Language
,	O
which	O
is	O
a	O
programming	O
or	O
scripting	B-Language
language	I-Language
used	O
extensively	O
in	O
web	O
browsers	O
,	O
this	O
is	O
an	O
important	O
keyword	O
,	O
although	O
what	O
it	O
evaluates	O
to	O
depends	O
on	O
where	O
it	O
is	O
used	O
.	O
</s>
<s>
When	O
a	O
method	B-Language
is	O
called	O
using	O
the	O
new	O
keyword	O
(	O
e.g.	O
</s>
<s>
When	O
a	O
function	O
is	O
attached	O
as	O
a	O
property	B-Language
of	O
an	O
object	O
and	O
called	O
as	O
a	O
method	B-Language
of	O
that	O
object	O
(	O
e.g.	O
</s>
<s>
For	O
example	O
,	O
the	O
method	B-Language
call	I-Language
obj.f(x )	O
could	O
also	O
be	O
written	O
as	O
obj.f.call(obj, x )	O
.	O
</s>
<s>
To	O
work	O
around	O
the	O
different	O
meaning	O
of	O
this	O
in	O
nested	O
functions	O
such	O
as	O
DOM	O
event	O
handlers	O
,	O
it	O
is	O
a	O
common	O
idiom	O
in	O
JavaScript	B-Language
to	O
save	O
the	O
this	O
reference	B-Language
of	O
the	O
calling	O
object	O
in	O
a	O
variable	O
(	O
commonly	O
called	O
that	O
or	O
self	B-Operating_System
)	O
,	O
and	O
then	O
use	O
the	O
variable	O
to	O
refer	O
to	O
the	O
calling	O
object	O
in	O
nested	O
functions	O
.	O
</s>
<s>
Notably	O
,	O
JavaScript	B-Language
makes	O
use	O
of	O
both	O
this	O
and	O
the	O
related	O
keyword	O
self	B-Operating_System
(	O
in	O
contrast	O
to	O
most	O
other	O
languages	O
which	O
tend	O
to	O
employ	O
one	O
or	O
the	O
other	O
)	O
,	O
with	O
self	B-Operating_System
being	O
restricted	O
specifically	O
to	O
web	O
workers	O
.	O
</s>
<s>
Finally	O
,	O
as	O
a	O
reliable	O
way	O
of	O
specifically	O
referencing	O
the	O
global	O
(	O
window	O
or	O
equivalent	O
)	O
object	O
,	O
JavaScript	B-Language
features	O
the	O
globalThis	O
keyword	O
.	O
</s>
<s>
In	O
Lua	O
,	O
self	B-Operating_System
is	O
created	O
as	O
syntactic	O
sugar	O
when	O
functions	O
are	O
defined	O
using	O
the	O
:	O
operator	O
.	O
</s>
<s>
When	O
invoking	O
a	O
method	B-Language
using	O
:	O
,	O
the	O
object	O
being	O
indexed	O
will	O
be	O
implicitly	O
given	O
as	O
the	O
first	O
argument	O
to	O
the	O
function	O
being	O
invoked	O
.	O
</s>
<s>
Lua	O
itself	O
is	O
not	O
object-oriented	B-Language
,	O
but	O
when	O
combined	O
with	O
another	O
feature	O
called	O
metatables	O
,	O
the	O
use	O
of	O
self	B-Operating_System
lets	O
programmers	O
define	O
functions	O
in	O
a	O
manner	O
resembling	O
object-oriented	B-Language
programming	I-Language
.	O
</s>
<s>
In	O
PowerShell	O
the	O
special	O
automatic	B-General_Concept
variable	I-General_Concept
$_	O
contains	O
the	O
current	O
object	O
in	O
the	O
pipeline	O
object	O
.	O
</s>
<s>
In	O
Python	B-Language
,	O
there	O
is	O
no	O
keyword	O
for	O
this	O
.	O
</s>
<s>
Thus	O
,	O
the	O
obligatory	O
first	O
parameter	O
of	O
instance	B-Language
methods	I-Language
serves	O
as	O
this	O
;	O
this	O
parameter	O
is	O
conventionally	O
named	O
self	B-Operating_System
,	O
but	O
can	O
be	O
named	O
anything	O
.	O
</s>
<s>
In	O
class	B-Application
methods	I-Application
(	O
created	O
with	O
the	O
classmethod	O
decorator	O
)	O
,	O
the	O
first	O
argument	O
refers	O
to	O
the	O
class	O
object	O
itself	O
,	O
and	O
is	O
conventionally	O
called	O
cls	O
;	O
these	O
are	O
primarily	O
used	O
for	O
inheritable	O
constructors	O
,	O
where	O
the	O
use	O
of	O
the	O
class	O
as	O
a	O
parameter	O
allows	O
subclassing	O
the	O
constructor	O
.	O
</s>
<s>
In	O
static	B-Language
methods	I-Language
(	O
created	O
with	O
the	O
staticmethod	O
decorator	O
)	O
,	O
no	O
special	O
first	O
argument	O
exists	O
.	O
</s>
<s>
In	O
Rust	B-Application
,	O
types	O
are	O
declared	O
separately	O
from	O
the	O
functions	O
associated	O
with	O
them	O
.	O
</s>
<s>
Functions	O
designed	O
to	O
be	O
analogous	O
to	O
instance	B-Language
methods	I-Language
in	O
more	O
traditionally	O
object-oriented	B-Language
languages	I-Language
must	O
explicitly	O
take	O
self	B-Operating_System
as	O
their	O
first	O
parameter	O
.	O
</s>
<s>
These	O
functions	O
can	O
then	O
be	O
called	O
using	O
instance.method( )	O
syntax	O
sugar	O
.	O
</s>
<s>
The	O
remaining	O
three	O
all	O
take	O
a	O
self	B-Operating_System
parameter	O
in	O
a	O
variety	O
of	O
ways	O
,	O
and	O
can	O
be	O
called	O
on	O
a	O
Foo	O
instance	O
using	O
the	O
dot-notation	O
syntax	O
sugar	O
,	O
which	O
is	O
equivalent	O
to	O
calling	O
the	O
type-qualified	O
function	O
name	O
with	O
an	O
explicit	O
self	B-Operating_System
first	O
parameter	O
.	O
</s>
<s>
The	O
Self	B-Operating_System
language	O
is	O
named	O
after	O
this	O
use	O
of	O
"	O
self	B-Operating_System
"	O
.	O
</s>
<s>
Self	B-Operating_System
is	O
strictly	O
used	O
within	O
methods	O
of	O
a	O
class	O
.	O
</s>
<s>
Another	O
way	O
to	O
refer	O
to	O
Self	B-Operating_System
is	O
to	O
use	O
::	O
.	O
</s>
