Some commentary to previous posts:
I think there are two different matters
1.- The type forward Declaration like this to avoid circular reference:
Type
PListItem = ^TListItem;
TListItem = Record
Data : Integer;
Next : PTListItem;
end;
2.- The type substitutions as presented, where the <_T> token is substituted by other value by specialize. Not circular reference. In the example
Container<_T>= class
public
data:_T;
pdata:^_T;
size:ptruint;
constructor create;virtual;
destructor destroy; override;
end;
pdata doesn't allow even pdata:^data. Compiler considers that a generic type is not specified (false, it's specified) , not a circular reference that in case 1. For that reason i didn't see the solution pointed by Blaazen. I think the declaration without a forward type in generics should be ok. (if _T is substituted by specialization there isn't circular reference nor ambiguity).
And thinking more: I even i don't know why
public type P_T = ^_T; works. I do not know why compiler allow this (the public type directive?)
On the other hand. I didn't put inherited on constructor and destructor because that class goes directly from TObject. AFAIK tobject create and destroy methods are empty/null, and the memory reserve/destruction are performed by the constructor and destructor keyword. Should be used inherited in a direct Tobject descendant class? Has any meaning? (perhaps helpers changing the TObject constructor behaviour? is this possible?)