[fpc-devel] [Suggestion] Enumeration range-check intrinsic
Michael Van Canneyt
michael at freepascal.org
Fri Jul 5 11:14:48 CEST 2019
On Fri, 5 Jul 2019, Martok wrote:
> Am 05.07.2019 um 10:47 schrieb Michael Van Canneyt:
>> Note that the explanation is IMO fuzzy, not to say contradictory:
>>
>> 'An enumerated type defines an ordered set of values by simply listing identifiers that denote these values'
>>
>> is at odds with (under the heading 'Enumerated Types with Explicitly Assigned Ordinality'):
>>
>> 'An enumerated type is, in effect, a subrange'
>
> No contradiction here: the corresponding implied subrange goes from lowest to
> highest assigned value, which is 0..n for dense enumerations and
> low(consts)..high(consts) for Enumerated Types with Explicitly Assigned
> Ordinality. There is nothing special about the holes, they just have no names.
IMO The whole point of an enumerated is to have the names for all allowed
values. i.e. I would write 'by simply listing all allowed identifiers' in the above.
But I will not argue the point, it is largely a matter of personal interpretation
of the intended use of an enumerated.
But I will definitely adapt the FPC documentation to be more clear about the actual
behaviour of the compiler.
Michael.
More information about the fpc-devel
mailing list