[fpc-devel] is that intended? private type section in classes versus visibility
Hans-Peter Diettrich
DrDiettrich1 at aol.com
Fri Jul 23 14:09:33 CEST 2010
Paul Ishenin schrieb:
> 23.07.2010 9:20, Paul Ishenin wrote:
>>> Is that intended? Or should a visibility change exit the type section?
>>
>> This is a bug. I will fix it.
>
> What to do with the generics syntax? FPC do this so:
>
> generic TFPGList<T> = class(TFPSList)
> type public
> TCompareFunc = function(const Item1, Item2: T): Integer;
> var protected
> FOnCompare: TCompareFunc;
> function ItemPtrCompare(Item1, Item2: Pointer): Integer;
> public
> constructor Create;
> end;
This IMO is the wrong way. Remember that visibility sections require
(Delphi) that field declarations are not preceded by other (method...)
declarations. In so far a visibility specifier is somewhat equivalent to
"var". The "interface" and "implementation" sections also are kind of
visibility specifiers.
If we ever should agree that declaration sections (var, type...) can be
split into subsections of different visibility, then this should apply
to the entire interface part, not only to (inside) class declarations.
At the same time we should allow for (kind of, implied) "forward"
declarations for types, so that the final declaration of non-public
types can be moved into the implementation section - reducing chances
for circular unit references a lot! (kind of "partial" class declarations?)
DoDi
More information about the fpc-devel
mailing list