[fpc-pascal] private type and type compatibility

Jonas Maebe jonas.maebe at elis.ugent.be
Wed Oct 30 14:37:02 CET 2013


On 30 Oct 2013, at 14:30, Xiangrong Fang wrote:

> 2013/10/30 Jonas Maebe <jonas.maebe at elis.ugent.be>
>
>> The tdynarray type is not visible in the program because u1 is not  
>> in its
>> uses clause (it's not in scope whatsoever), and nevertheless there  
>> is no
>> problem to use it. It's of course not exactly the same (tdynarray  
>> isn't
>> declared as private to u1), but at the scope visibility level it is  
>> the
>> same situation as far as I am concerned.
>
> ​I don't think they are the same.  tdynarray​
> is not usable in main program because you did not uses u1, NOT  
> because the
> type is defined as PRIVATE!

"Private" is just another way to define a scope, just like a unit  
interface and implementation define a scope. Neither the "private"  
section nor the interface of unit "u1" is in scope when the "hidden"  
type is used.


Jonas


More information about the fpc-pascal mailing list