On Sat, 29 May 2010, spir ☣ wrote:

On Sat, 29 May 2010 01:09:50 +0300
Alberto Narduzzi <albertonardu...@yahoo.com> wrote:

Hi,

Struct is declared as "class" so it inherits from TObject if not other
class is especified.

is that true? I don't mean not to trust you, but is the compiler
assuming that, or is it a FPC rule? IMO a class is a class, and doesn't
inherit from anything else. Unless specified. BTW, From who does TObject
inherit then?
Just asking, I never declare anything as a pure class, or if I do I
don't care if it descends from TObject or not, actually...

Hum, there must be a root type, from which all others inherit primitive object 
mechanics. Such as, and mainly, accessing an attribute. Now, this needs not be 
obvious on the user-language side, but generally it is. So a test such as 
anything.isOfType(RootObject) always returns true.
Don't know about free pascal, but this is very probable (and I assumed it's 
true before the question was raised).

All classes descent from TObject, always: implicitly or explicitly.

I take the opportunity to ask about inherited attribute (only methods in FP?) 
transmission and lookup: there are 2 common schemes:
* Copy: A subclass holds copies of (references to) inherited methods. So, 
lookup stops on an object's class.
* Delegation: A subclass delegates to its superclass when a looked up attribute 
is not found locally. (The superclass may itself delegate further, this up to 
the root class.)

Static methods are directly bound by the compiler.
For virtual methods: the actual pointer to the method is in the VMT
A pointer to the VMT is initialized when an instance is created. But I am not sure whether VMTs are linked or whether they are copied for
descendents.

Michael.
_______________________________________________
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal

Reply via email to