[fpc-devel] Records nesting/inheritance?

Michael Van Canneyt michael at freepascal.org
Wed Aug 5 08:20:45 CEST 2015



On Wed, 5 Aug 2015, Чернов Дмитрий wrote:

> Good day everyone.
>  
> Recently I've tried to write some social network parsing code and faced with numerous nesting of structures (records).
> When I completely tired to write things like Friend.BaseUser.City.ID ("real programmer will never get complerely tired", hah - yes, I know), I thought out that it might be cool to have such a
> feature as structures inheritance.
> I'm not very good in English, so, instead of describing everything I'll just try to write an example:
>  
> http://pastebin.com/Pm701Nh4
>  
> So, there's examples of addressing some fields with and without this feature:
> Friend.BaseUser.FirstName  >> Friend.FirstName
> Friend.UserInfo.Country.ID >> Friend.Country.ID

You can do this already with extended records, just declare properties.

http://www.freepascal.org/docs-html/ref/refse51.html#x107-1170009.1

Michael.


More information about the fpc-devel mailing list