[fpc-devel] is that intended? private type section in classes versus visibility

Martin fpc at mfriebe.de
Fri Jul 23 03:54:12 CEST 2010


On 23/07/2010 02:46, Paul Ishenin wrote:
>
> 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;
even in this example, the standalone "public" ends the type ?

>
> while Delphi do so:
>
>   TSomeClass = class
>   public
>    type
>      TCompareFunc = function(const Item1, Item2: T): Integer;
>    protected
>     var
>      FOnCompare: TCompareFunc;

Don't know which one is best. but IMHO there are 3 ways that could make 
sense:


1) type, const, ... are nested inside the visibility
They end with the visibility => same as they end with the end of an 
interface section...

2) visibility sections are nested inside type, const
honestly, not a good idea

3) combined keywords (IIRC harder to implement if the parser may have to 
look ahead)
then inside a class "var" can not stand alone, but only iof followed by 
a visibilty modifier....





More information about the fpc-devel mailing list