[fpc-pascal] WHY compiler should be public?

Michael Van Canneyt michael at freepascal.org
Fri Oct 25 09:16:27 CEST 2013

On Fri, 25 Oct 2013, Xiangrong Fang wrote:

> Hi,
> First of all, I did some research and found this:
> http://free-pascal-general.1045716.n5.nabble.com/Compiler-Warning-Constructor-should-be-public-td2825747.html
> But that did not convince me. So here is my situation and question.
> I have the following case:
> TBase = class
> public
>   constructor Create;                         //VER-0
> end;
> TDerived = class(TBase)
> private
>   constructor Create(param1);                 //VER-1 
> public
>   constructor Create; reintroduce;            //VER-0'
>   constructor Create(param1, param2);         //VER-2
>   constructor Create(param1, param2, param3); //VER-3
> end;
> My purpose is that while using TDerived, only VER-2
> and VER-3 of the constructors should be used, VER-0
> and VER-1 are used INTERNALLY by VER-2 and VER-3 and
> should NOT be used publicly.

Why not simply make it a procedure that is called by ver-2 and ver-3.

If it cannot be called directly from external code, and will called only 
from inside a visible consructor, there is simply no reason to make this 
procedure a constructor. A simple procedure will do.


More information about the fpc-pascal mailing list