[fpc-pascal] Set size limit
Mark Morgan Lloyd
markMLl.fpc-pascal at telemetry.co.uk
Mon Mar 11 15:10:08 CET 2013
Daniel Gaspary wrote:
> On Mon, Mar 11, 2013 at 7:09 AM, Mark Morgan Lloyd
> <markMLl.fpc-pascal at telemetry.co.uk> wrote:
>> That was pretty much my gist. Since these days Unicode is larger than 65536
>> codepoints I don't think there's any advantage to expanding sets from 256 to
>> 65536 elements, efficient operations on sparse arrays of 256-element sets
>> would be far better.
>
> In my case the enum has near 600 elements.
>
> TMyEnum = (me1, me2...);
>
> The set though would never be used to contain more than 256.
>
> TMySet = set of TMyEnum;
>
> Is it not viable to modify the compiler to compile the code and raise
> an exception if I try to add more than 256 elements to the set ?
No, because the elements in a set are dictated by their position. A set
that can contain anything between 0 and 256 elements occupies 8 bytes in
memory with the (bit representing the) 0 element at one end and the (bit
representing the) 256 element at the other, a set to contain up to (say)
257 elements would require more space and that's not supported.
--
Mark Morgan Lloyd
markMLl .AT. telemetry.co .DOT. uk
[Opinions above are the author's, not those of his employers or colleagues]
More information about the fpc-pascal
mailing list