During the last few seconds, i implemented implicit "this".
Which means that its not necessary to use "this" inside a method for accessing a member of the "this" instance.
However. If you dont use "this", the precompiler first searches the current method for a declared var of this name, if its not found, it searches the class of this method for a member with this name. As you cann see, if you have a class with a member called "FCount" and a method with a lokal var called "FCount", the compiler will priorize the lokal var and NOT use the member of the Class.
example input: (CList has a var of type int called FCount)
void CList::Remove(int AIndex)
{
int i;
if(clamp(AIndex, 0, FCount-1) == AIndex)
{
for (i = AIndex; i < FCount-2; i++)
{
(FItems)[i] = (FItems)[i+1];
}
FItems = sys_realloc(FItems, sizeof(int), FCount, FCount-1);
FCount -= 1;
}
}
example output:
void GenesisCListRemove(CList* this, int AIndex)
{
int i;
if(clamp(AIndex, 0, this.FCount-1) == AIndex)
{
for (i = AIndex; i < this.FCount-2; i++)
{
(this.FItems)[i] = (this.FItems)[i+1];
}
this.FItems = sys_realloc(this.FItems, sizeof(int), this.FCount, this.FCount-1);
this.FCount -= 1;
}
}
but this behaves differently:
input:
void CList::Remove(int AIndex)
{
int i;
int FCount;
if(clamp(AIndex, 0, FCount-1) == AIndex)
{
for (i = AIndex; i < FCount-2; i++)
{
(FItems)[i] = (FItems)[i+1];
}
FItems = sys_realloc(FItems, sizeof(int), FCount, FCount-1);
FCount -= 1;
}
}
output:
void GenesisCListRemove(CList* this, int AIndex)
{
int i;
int FCount;
if(clamp(AIndex, 0, FCount-1) == AIndex)
{
for (i = AIndex; i < FCount-2; i++)
{
(this.FItems)[i] = (this.FItems)[i+1];
}
this.FItems = sys_realloc(this.FItems, sizeof(int), FCount, FCount-1);
FCount -= 1;
}
}
As you can see from this example, the lokal var has a higher priority/visibility.
Greetings
Rackscha