I have validly used self I'm sure, but I can't remember why? Perhaps it's when I have a local variable in a method called X or something, and then I want to access the type's X field so I've used self.x. But that would be pretty lame code...
Aha just searched my code, and the most common use is when I have extended TList and I want to loop through it so I do For Local o:TObject = eachin self for example.
Also sometimes I have a list of objects and I want the objects to reference the list, so when I make a new object via the list (say with a method called AddNewObject), I set a field on the object to be Self (which is the list). Then later I can get the object to remove itself from the list by looking at its field which references the list and then calling TheList.Remove(self) which removes the object. Hmm I'm probably not being very clear, but yeah it can be useful.
A final use is, say a method on a Type calls an external function that you've designed to work on that sort of type, and the function needs one of those types passed into it as a parameter, well you can pass the parameter in as self of course!
Aha just searched my code, and the most common use is when I have extended TList and I want to loop through it so I do For Local o:TObject = eachin self for example.
Also sometimes I have a list of objects and I want the objects to reference the list, so when I make a new object via the list (say with a method called AddNewObject), I set a field on the object to be Self (which is the list). Then later I can get the object to remove itself from the list by looking at its field which references the list and then calling TheList.Remove(self) which removes the object. Hmm I'm probably not being very clear, but yeah it can be useful.
A final use is, say a method on a Type calls an external function that you've designed to work on that sort of type, and the function needs one of those types passed into it as a parameter, well you can pass the parameter in as self of course!