[fpc-devel] Record types with unbounded trailing data
J. Gareth Moreton
gareth at moreton-family.com
Mon Jun 24 07:36:00 CEST 2019
Well, that's when I said that a new keyword may be necessary so there's
no ambiguity, but in this case, for a single open array, the two are
effectively equivalent. Even in cases where you might pass the array
through the Move routine, you wouldn't do it for the entire record (or
an array of them) because of the dynamic array's hidden fields. A
record having multiple dynamic arrays would probably not be eligible for
such unbounded treatment.
Some of the semantics would need to be figured out still, but that's
assuming it doesn't stay shot down.
Gareth aka. Kit
P.S. There is some danger with redefining LOGPALETTE to have an upper
bound of MAXINT on the array, and that's SizeOf(LOGPALETTE) returning an
excessively large value, something that would be passed into GetMem and
potentially trigger an EOutOfMemory exception (or worse, not, but
potentially cause excessive thrashing in a non-obvious way).
On 24/06/2019 06:23, Sven Barth via fpc-devel wrote:
> Am 24.06.2019 um 05:57 schrieb J. Gareth Moreton:
>> We can't really use a new keyword to define an unbounded array, so
>> I'm wondering if we can work with the syntax for open arrays. For
>> example, say we redefined LOGPALETTE to the following:
>>
>> LOGPALETTE = record
>> palVersion : WORD;
>> palNumEntries : WORD;
>> palPalEntry : array of PALETTEENTRY;
>> end;
> Michael already shot this, but nevertheless: if you would use that
> syntax then how would you differentiate from records that really
> contain a dynamic array and not such a unbounded one?
>
> Regards,
> Sven
> _______________________________________________
> fpc-devel maillist - fpc-devel at 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
More information about the fpc-devel
mailing list