On 30 Oct 2013, at 10:36, Michael Van Canneyt wrote:

I think it is an error. You declare something as private, and then you use it in a public function ? If that is not a visibility clash, I don't know what is :)

The ability to use types in public functions that are not necessarily visible to users of that function is quite common in Pascal. Otherwise, for consistency you would also have to give a compile time error when compiling this:

unit u1;

interface

type
  tdynarray = array of integer;

implementation

end.
*********

unit u2;

interface

uses
  u1;

function f: tdynarray;

implementation

function f: tdynarray;
begin
end;

end.
**********

program test;

uses
  u2;

var
  a: array of integer;
begin
  a:=f;
end.
***

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.


Jonas
_______________________________________________
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal

Reply via email to