Ah yes, that works, thanks.
I feel a bit silly because I haven't explored these useful features as
much as I should, possibly because assembly language isn't object oriented!
I think the difficulty with getting things like this approved is that it
crosses into the realm of defining the language itself. I can't say I
speak on behalf of Florian or Jonas, but I sense they want to avoid
feature bloat that became a bit of an issue with Delphi.
Gareth aka. Kit
On 17/09/2020 04:03, Ryan Joseph via fpc-devel wrote:
On Sep 17, 2020, at 9:59 AM, J. Gareth Moreton via fpc-devel
<fpc-devel@lists.freepascal.org> wrote:
type generic TMyArray<T> = record
Data: ^T;
Length: PtrUInt;
end;
The compiler will complain about T being an unresolved forward declaration.
Outside of specifying a second parameter for the pointer type (which would be a
little unfriendly for third-party users), there isn't really a way around this.
To be clear all the features work but it's not as optimized as dynamic arrays
and could be cumbersome with arrays of records.
I think you're supposed to redeclare a pointer to T:
type generic TMyArray<T> = record
type
TP = ^T;
public
Data: TP;
Length: PtrUInt;
end;
Regards,
Ryan Joseph
_______________________________________________
fpc-devel maillist - fpc-devel@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel
--
This email has been checked for viruses by Avast antivirus software.
https://www.avast.com/antivirus
_______________________________________________
fpc-devel maillist - fpc-devel@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel