[fpc-devel] protected class section / documentation

Michael Van Canneyt michael at freepascal.org
Thu Jan 8 13:24:44 CET 2026



On Thu, 8 Jan 2026, Martin Frb via fpc-devel wrote:

> On 08/01/2026 10:01, Michael Van Canneyt via fpc-devel wrote:
>>
>>
>> On Wed, 7 Jan 2026, Martin via fpc-devel wrote:
>>
>>> According to https://www.freepascal.org/docs-html/ref/refse34.html
>>>
>>>> Protected
>>>>     Is the same as Private, except that the members of a Protected
>>>>     section are also accessible to descendent types, even if they are
>>>>     implemented in other modules. 
>>>
>>> "to descendant types" => suggests, from within a descendant type 
>>> (even if the descendant type is in a different unit).
>>>
>>> But the example (working with 3.3.1) from 
>>> https://gitlab.com/freepascal.org/lazarus/lazarus/-/issues/41987 
>>> shows that the protected method is accessible
>>> *_through_* the descendant type.
>>>
>>> I.e. from any code in the unit of the descendant type, even code 
>>> outside the descendant type, if it goes "through" the descendant type.
>>
>> What is your question ?
>
> Should the doc be clearer on this?
>
> - "to" in "to descendant types" from an English point of view says "the 
> descendant themself" or "the code inside the descendant"

Yes, because that is what is meant.

What you observe is a corollary of the scoping rules as I explained above. 
I'll add a remark.

Michael.


More information about the fpc-devel mailing list