Hi,
I have to throw out some points here:
* Unfortunately, your solution is not giving me a pointer of TNode<T>, your "PNode" is still
just a specialized record, not a pointer to it.
* Lets assume, even if this would work, I gotta say, its an actually disgusting syntax, no
hate at this point (I love FPC with my heart) but there are some implications which I
really find deeply unintuitive, for instance:
* When I want to create a pointer type of any generic type, I should actually be able,
like with any pointer type, to get this code running:
generic PNode<T> = ^specialize TNode<T>
cuz this is IMHO very intuitive, it
says: "give me the adress of TNode<T> so I need to specifiy the T also within the
brackets of PNode. This would be atleast one of the logical syntax-assumptions:
* To the general way of generics , why am I not just able to create a:
generic TBla<T>= specialize TElement<T>;
This or any other variations I tried doesnt work also, like: I have a unit, called Collection, within that unit, I want to
create global accessable types from that unit which are accessible publicly, so more concrete:
type
generic TElement<T> = record
//some fields, no pointer to itself here!
end;
PNode = ^specialize TNode; //something along these lines should work but as I mentioned above, I would
//find it even more clear to saay: generic PNode<T> = ^specialize TNode<T>
generic TNode<T> = record
Next: PNode; //make a PNode here possible instead of writing ^TNode;
Previous: PNode; //make a PNode here possible instead of writing ^TNode;
Data: array of specialize TElement<T>; //specialize here is ok!
class operator =(const this, other: TNode) : Boolean;
class operator <>(const this, other: TNode) : Boolean;
end;
generic TSomeDifferentCollection<T> = record
private
//make a PNode here possible instead of writing ^TNode;
fFirst: PNode; //<----
public
//make a PNode here possible
function BlockAlloc(const cnt: TMaxCapacity; const shallGrow: Boolean): PNode; //<----
end;
I hope, since generics are still as I looked into it, described as being in an experimental state and I hope there can be some more intuitive syntax, since its just , as it is right now, not the most pascalish-clear syntax, as it could be.
But I still appreciate obviously all the help and general interesst in these argumentations.