[fpc-devel] Differences between 'tsym' and 'tdef'

Joost van der Sluis joost at cnoc.nl
Fri May 18 08:23:57 CEST 2012


On Fri, 2012-05-18 at 06:30 +0800, Paul Ishenin wrote:
> 18.05.12 5:32, Joost van der Sluis wrote:
> 
> > Now I'm wondering if I should make this new field of Tpropertysym a TDef
> > or a TSym(table). I know that Tsym can store itself to a ppu while a
> > TDef does not. But There was something else, too. But I don't remember
> > exactly.
> 
> TSym is about symbol and TDef is about definition. Each symbol is just 
> an identifier which compiler founds during parse which may have > 1 
> definitions (overloaded functions for example). A definition does not 
> have a name (generally) but instead have information how to work with 
> it. It may refer to no symbol at all. Both are stored in a TSymTable and 
> ppu (look at TStoredDef).
> 
> A property does not have a definition of itself - only a symbol and list 
> of fields/procedures for read,write,stored.

Thanks.

> > So two questions: how should I extend the Tpropertysym for the extended
> > attributes, and what is the dfference/use of Tdef and Tsym.
> 
> Does any symbol in delphi may have this information? If property has 
> this information and you created a descendant property - will it have 
> the same attributes as an ancestor property?

This information can be bound to a properties but also whole classes at
least. (I'll have to test for methods and public fields) So no, not only
properties may have this information.

And, to answer your second question, properties in a descendant class do
*not* inherited the properties of the ancestor. I found that pretty
strange, but that's how it is implemented in Delphi. 

> For now if only property may have this information then choose 
> TPropertySym for storing it.

So in this case create a special symbol and symtable for it?

Joost.




More information about the fpc-devel mailing list