[fpc-pascal] private type and type compatibility

Martin lazarus at mfriebe.de
Wed Oct 30 15:19:10 CET 2013


On 30/10/2013 13:49, Xiangrong Fang wrote:
> 2013/10/30 Martin <lazarus at mfriebe.de <mailto:lazarus at mfriebe.de>>
>
>
>     I think there is no problem with:
>
>     var
>       a: array of Integer
>     begin
>       A:= obj.proc;
>
>     You are NOT using the type. You are using the value.
>
>
> pascal is strong-typed.  You are actually using type along with its 
> value.  e.g.
>
> var
>   a: array of Double;
> begin
>   a := obj.proc;
>
> This will emit a COMPILE time error because compiler know these 2 
> types are not compatible.
>

Yes. But what I mean is, your code does not refer to the type directly.

Since the type is part of value, and the value is public, all of the 
type that is accessed through the value is available.
Same as you can access a private field through a public property.

However the type itself (as referenced by the identifier in the type 
declaration), that is the type without a value, is not used by your code.
You do not declare a new variable of that type.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-pascal/attachments/20131030/65207f0c/attachment.html>


More information about the fpc-pascal mailing list