2013/10/30 Jonas Maebe <jonas.ma...@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
_______________________________________________
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal

Reply via email to