[fpc-devel] Fwd: New Issue: Accessibility Declarations for FreePascal

Martin Frb lazarus at mfriebe.de
Mon Oct 19 18:38:54 CEST 2026


Can someone comment on this?

Do we have C-like distinction between access and visible?

I would think not?

If you can access it you can see it, and vice versa?
I can't think of any other case (i.e. where an identifier would be 
hidden by something that you can't access like in the example below)

We do have the reverse, that a public property/function can expose a 
private type (but not the name of the type, just its "content" 
(enum/members))



-------- Forwarded Message --------

	

	

	

	

	



Martin,

Last week, while we were discussing the FreePascal accessibility 
declarations, I began to wonder whether the private/strict 
private/protected/strict protected keywords really were accessibility 
values or visibility values.  In the reference manual, it uses both 
terms interchangeably.  It says, "The visibility of the different 
sections is...", but then in the text for each value, it uses verbiage 
like "can be accessed".  In C++, there are situtations where visibility 
vs. accessibility is an important distinction.  My go-to to expose this 
is hiding rules.  For example:

    int foo = 1;

    class C {
    private:
        int  foo {2};
    };

    class D : public C {
    public:
        void func()
        {
           // illegal because C::foo is visible here, but not accessible.
           // Because C::foo is visible, it hides ::foo.
           std::cout << foo << '\n';
        }
    };

Or another example:

    class C {
    public:
        int foo { 1 };
    };

    class D : public C {
    private:
        int foo { 2 };
    };

    int main()
    {
        D  obj;
        // illegal because D::foo is visible here, but not accessible.
        // Because D::foo is visible here, it hides C::foo.
        std::cout << obj.foo << '\n';
    }

My question is: In FreePascal, are there situations like this where the 
private/strict private/protected/strict protected names can hide other 
names at global scope?  Or at any "outer" scope, for that matter, if 
these constructs can be declared arbitrarily nested within other 
constructs, like in Ada.  If they all can hide names, to my mind, that 
rules out using visibility as any part of the description.  Instead, if 
none of them can hide other names, then perhaps all of them should be 
visibility values instead.  Or, if it's impossible to construct an 
example in FreePascal that can tell the difference, then perhaps I'm 
just splitting hairs.  :)

Regards,
Todd Allen
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-devel/attachments/20261019/bde2d00e/attachment.htm>


More information about the fpc-devel mailing list