[fpc-pascal] private type and type compatibility
Xiangrong Fang
xrfang at gmail.com
Wed Oct 30 14:30:45 CET 2013
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!
As a matter of fact, if you define tdynarray as private (not in interface
section), there is no way you can use it as a return type of an exported
(public) function. This is a very consistent scoping rule!
In my example, if the code is like this:
generic TVector<T> = class
private type
TDataType = array of T;
private
function proc: TDataType;
end;
Then I think it is ok, because this PRIVATE type is used by PRIVATE
function.
What do you think?
Sincerely,
Xiangrong
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-pascal/attachments/20131030/a8c0a9ae/attachment.html>
More information about the fpc-pascal
mailing list