[fpc-pascal] Implementing a true Singleton - Can we decrease the visibility of a method?
Andreas at TheBergerClan.org
Fri Dec 8 14:39:41 CET 2006
Graeme Geldenhuys wrote:
> On 12/8/06, TOndrej <tondrej at gmail.com> wrote:
>> On 12/8/06, Graeme Geldenhuys <graemeg.lists at gmail.com> wrote:
>> > I still don't know why we can't decrease visibility in Free Pascal.
>> > Is there some internal language design that prevents it?
>> A class definition (or at least its parts visible from outside) can be
>> understood as a kind of contract. If you have a class TDog with a
>> public property Tail then, by definition, any TDog descendant
> I understand your example and that makes sense, but would be handy in
> certain cases to change it.
A TBoxer could be considered a TDog without a tail :)
>> I'm not even sure if there is a language which allows demoting
>> visibility of inherited class members. It would seem odd to me. Just
>> my 2c, of course. ;-)
> C++, C#, VB.Net are three I know of. I think Java also allows it.
Yes, but that causes other problems. I worked for a time for a company
that wrote programs for aeronautical equipment. In these cases the above
mentioned languages could not be used. C was ok, and C++ could only be
used if you followed very strict rules (and a lint program to guarantee
you were following the rules). Pascal however had far fewer restrictions
(almost none if I remember correctly). Modula-2 could be freely used. If
we relax the Pascal rules we will end up with a non-secure language like
More information about the fpc-pascal