[fpc-devel] generics and scoping rules

Sven Barth pascaldragon at googlemail.com
Sat May 9 09:35:08 CEST 2015


Am 08.05.2015 23:56 schrieb "Martin Frb" <lazarus at mfriebe.de>:
>
> What are the scoping rules?
>
> Example:
>
>   TLazStorageMemBase = object
>   private
>   const
>     CNT_OFFS  = SizeOf(Pointer);
>     DATA_OFFS = CNT_OFFS + (2 * SizeOf(Integer));
>   private
>     FMem: PByte;
>     function GetCapacity: Integer; inline;
>     function GetCount: Integer; inline;
> .....
>   end;
>
>   generic TLazGenStorageMem<T> = object(TLazStorageMemBase)
> ...
>     property Capacity: Integer read GetCapacity write SetCapacity;
>     property Count: Integer read GetCount;
>   end;
>
>
> If I specialize TLazGenStorageMem in an other unit, then I get tons of
errors, because all the privet symbols are not accessible.
>
> Is that intended?

I'd say that this is not intended, but I'll need to retest this with Delphi.

You forgot one very important piece of information though: what compiler
version are you using? If it's 2.6.x, then please test with 3.0.1 or 3.1.1
as there were /many/ changes since then and 2.6.4's generic support is
nothing compared to what we now have (despite there still being quite some
bugs and missing features).

Regards,
Sven
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-devel/attachments/20150509/9509be57/attachment.html>


More information about the fpc-devel mailing list