Default methods are published

I guess this has always been there. For the first time, for a bunch of classes, I didn’t have any private fields, so I didn’t put a public declaration.

  1. It seems that the default is published - this is silly in my opinion. It should either be public or it should flag it.

  2. For overloaded methods here, the error is silly - I had to scratch my head and waste some time before realising that perhaps the problem was that overloaded methods were not allowed in published section. And the word “published” did not register at first as I was expecting them to be public.

    The error was

    [Error] Remote.Picklists.pas(54): Duplicate published method “Filter_Data” at I:\DELPHI\PROJECTS\Helicopters\Project\ops\Remote.Picklists.pas(53,26)

    It should be

    Overload not allowed in published methods

  TNewClientDataset = class (WEBLib.CDS.TClientDataSet)
    FType : TPickList;
    procedure Is_Dirty;
    function  Not_Ready : Boolean;
    procedure Load_Data;
    procedure Filter_Data (AStatus : Trilean); overload;
    procedure Filter_Data (AActive : Boolean); overload;
    procedure Assign_Data (AItems : TArray<TPicklist_Item>);
  end;

Notes :

  1. Its actually being used in TMS Webcore project - hence the weblib.
  2. I have always had Trilean since Delphi 1. mentioning here in case it’s useful to others. I find it very versatile. In this case it allows me to filter records by Active, Inactive or none. You can define synonyms - which I do locally to suit. in the parent one, I have defined Unknown.
{ Trilean logic when Boolean is not enough }
type
  Trilean = (Maybe, No, Yes);
const
  Unknown = Maybe;

1 Like