[Lazarus] Forward declare (modern) records [was: Re: "global" operator overloading]

Sven Barth pascaldragon at googlemail.com
Wed Feb 27 17:00:47 CET 2013


Am 27.02.2013 13:22 schrieb "ListMember" <listmember at letterboxes.org>:
> Referring to your other post, you gave this example:
>
>
> === example begin ===
>
> type
>   SomeType1 = record;
>   SomeType2 = record;
>
>   SomeType1 = record
>     // ...
>     property SomeProperty: SomeType2 read ... write ...
>   end;
>
>   SomeType2 = record
>     // ...
>     property SomeProperty: SomeType1 read ... write ...
>   end;
>
> === example end ===
>
> While it does capture the idea, let me make it more detailed/clearer.

To be honest: I left out the methods, because of lazyness :)

> I only (wish to) use the forward declared record types in
methods/getters/setters/properties.
>
> Correct me if I am wrong, but this way we can eliminate the possiblity of
introducing infinite recursion (that would arise if we used forward
declared record types as fields).
>
> Is there still any logical flaw in this?

After having slept about it a bit, I came to the conclusion that your
proposal is at least a valid one considering that we already differentiate
between record field or not for the type itself. As a forward declaration
needs to be resolved in the same type section we don't need to bother about
global variable or function declarations either. What could be a bit
counterintuitive though is if there is a class, interface or object
declaration inbetween and that one uses the record as well... Depending on
when the sizes of the instances and parameters are calculated, we can
either allow or need to forbid its usage...

You can create a feature request on the bugtracker. I don't know yet
whether we'll definitely implement it or not, but this way it's up for
discussion. And please state there again that you don't want to use it for
fields.

Regards,
Sven
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus-ide.org/pipermail/lazarus/attachments/20130227/415470af/attachment-0003.html>


More information about the Lazarus mailing list