[fpc-pascal] Set limitations

Hairy Pixels genericptr at gmail.com
Sun Jan 12 01:57:47 CET 2025


 On Jan 11, 2025 at 10:53:36 PM, Sven Barth via fpc-pascal <
fpc-pascal at lists.freepascal.org> wrote:

> Set are a minimum of 4 Byte by default cause that's how Delphi does them.
> Ifets you want smaller sets then use the $PackSets directive as Martin had
> written.
>

I did not know this existed. I don’t see any reason they force the set to 4
bytes unless it was being used to pass to C libraries maybe?


> The maximum is also based on what TP and Delphi allow. ISO Pascal for
> example suggests a maximum of 1024 elements instead, though they define
> this number to be implementation specific.
> In the end it's a decision of where to do the cut as at some size the
> majority of the set will be sparsely populated so it makes more sense to
> use a dedicated type instead (e.g. a hash set or something like that) that
> wastes less memory.
>

Theoretically if you added one more element to 257 the size would double to
64 bytes right? That’s still only 50% of a short string both of which can
be sparsely populate so how are they different?

Regards,
    Ryan Joseph
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-pascal/attachments/20250112/abc86865/attachment-0001.htm>


More information about the fpc-pascal mailing list