[fpc-devel] Feature request/discussion - SetLengthNoInit
J. Gareth Moreton
gareth at moreton-family.com
Thu Sep 17 06:33:20 CEST 2020
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 at lists.freepascal.org> wrote:
>> type generic TMyArray<T> = record
>> Data: ^T;
>> Length: PtrUInt;
>> 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
> TP = ^T;
> Data: TP;
> Length: PtrUInt;
> Ryan Joseph
> fpc-devel maillist - fpc-devel at lists.freepascal.org
This email has been checked for viruses by Avast antivirus software.
More information about the fpc-devel