[fpc-pascal] generic class helper and class references
Sven Barth
pascaldragon at googlemail.com
Sun Sep 29 10:56:03 CEST 2013
On 29.09.2013 05:30, Xiangrong Fang wrote:
> type
> generic TTree<T> = class
> ... ...
> end;
> TTreeType = class of TTree;
This is illegal code and compiled by pre-2.7.1 FPC only because of bugs
in the generic implementation. "TTree" is not a legal type outside of
the generic's declaration or implementation (and no, TTree<T> is neither).
> 1) is it possible to define class helper for generic classes?
No. I recently had the thought to allow this as well, but not now.
> 2) why class helper require a class and we cannot use a class reference?
A class helper always work on variables (or return values) of the type
you specified. So if you'd be able to define a class helper for
TTreeType you'd only be able to use it on variables of type TTreeType or
e.g. TTreeType(Self.ClassType), but not on instances of TTree<>.
Regards,
Sven
More information about the fpc-pascal
mailing list