[fpc-devel] Optimization for TObject.InheritsFrom (and the 'is' operator)
Marco van de Voort
marcov at stack.nl
Sat Jul 21 21:17:27 CEST 2007
> Peter Vreman wrote:
> > There is no garauntee either within a single unit. With forward defined classes you can make any
> > order you want.
> >
> > And relying on order in memory has also problems with shared libraries. afaik there is no rule
> > that new libaries are always loaded at larger adresses
>
> Thank you for this information, Peter. I hadn't thought of shared
> libraries yet.
>
> Anyway, as far as I understood shared libraries each have their own VMTs,
> so you can't compare classes that come from different dll's or the main
> executable. Is that correct?
For pure shared libraries yes, for packages no. For packages, Peter is
right.
> BTW I now realize that I was using a little bit confusing terminology; with 'depth-first order traversal' I meant 'preorder traversal'. The 'NextSibling' and 'LastChild' names are also confusing. What I actually meant, I'd rather call 'NextSubtree' and 'LastInSubtree'.
>
> Consider the following example:
>
> TObject
> |
> +- TPersistent
> | |
> | +- TMyPersistent
> | |
> + +- TComponent
> | |
> | +- TDataset
> |
> +- TList
>
> Here:
> - TMyPersistent.NextSubtree = TComponent, .LastInSubtree = TMyPersistent
> - TComponent .NextSubtree = TList, .LastInSubtree = TDataset
> - TDataSet .NextSubtree = TList, .LastInSubtree = TDataset
> - TList .NextSubtree = <inf>, .LastInSubtree = TList
>
> An every-day example is a directory treeview, such as e.g. the left pane
> in Windows Explorer. When all nodes are expanded, iterating the rows from
> top to bottom corresponds exactly with preorder traversal. With this
> picture in mind, it is relatively easy to see the correctness of the
> proposed InheritsFrom implementation.
Assume everything on the 1st and 2nd level above is in a package A.
Progam B and C both use package A. What do we do about lastinsubtree?
More information about the fpc-devel
mailing list