[fpc-devel] Records nesting/inheritance?
Sven Barth
pascaldragon at googlemail.com
Wed Aug 5 08:08:08 CEST 2015
Am 05.08.2015 05:47 schrieb "Чернов Дмитрий" <blackdoomer at yandex.ru>:
> 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
>
> And let me clarify some details:
> - fields can not be overridden;
> - record can nest several records.
>
> Of course, somebody will try to advise me to use objects. :)
Of course, but probably not the objects you think about ("class"), but
their older cousins ("object"). ;)
> But never mind that
> a) in procedural programming we don't use objects,
"object" types behave like records with inheritance if they don't have
methods.
> b) objects are more complex that needed
Not true for "object" types.
> c) objects require additional routines for creating and destroying of
them.
Like records "object" types can be allocated on the stack.
So there is no need to burden "record" with another feature that's already
supported by "object".
Note: Multiple inheritance is however supported by none of the three
structured types ("record", "object", "class") and it wouldn't be added
anyway, so there you need to find a solution with normal inheritance.
Regards,
Sven
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-devel/attachments/20150805/3e641d4b/attachment.html>
More information about the fpc-devel
mailing list