[fpc-pascal] private type and type compatibility

Jonas Maebe jonas.maebe at elis.ugent.be
Wed Oct 30 12:32:46 CET 2013


On 30 Oct 2013, at 12:09, Sven Barth <pascaldragon at googlemail.com> wrote:

> Am 30.10.2013 11:59, schrieb Jonas Maebe:
>> 
>> 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.
> Hmm... but here the compiler can not know whether the unit using u2 has unit u1 in scope or not. In case of private and protected types the compiler can know however that code declared externally can never have access to it

It can, as demonstrated by the example that started this thread. The type identifier may not be visible, but entities that have this type can be. Just like in the unit example.

> (though of course there might be type compatibilities like your dynamic array example, but most private/protected types should be records or classes).

I'm not sure why most private types "should" be records/classes, especially with generic classes.


Jonas


More information about the fpc-pascal mailing list