On Fri, 5 Jul 2019, Ondrej Pokorny wrote:
Note: This is my opinion, it may be at odds with what the compiler
actually
implements :)
Read:
http://docwiki.embarcadero.com/RADStudio/Rio/en/Simple_Types_(Delphi)#Enumerated_Types_with_Explicitly_Assigned_Ordinality
As I said, my opinion may be at odds with what the compiler actually implements.
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'
But opinions may vary.
If memory serves well, FPC introduced this (before delphi) to be able to import
C enums with assigned values.
Btw. why nobody commented on my latest suggestion in
https://lists.freepascal.org/pipermail/fpc-devel/2019-July/041499.html ?
IMO this is a valid solution for both sides.
What part exactly ? The additional range check for a case in case of
range checking ?
Yes.
I don't see why you need it, since in case range checking is enabled,
the assignment of the variable should already have ensured that there
are only valid values in it.
The compiler can never catch all kinds of assignments and do range
checking on them (e.g. FillChar, Read, pointer-writes, etc. etc.). So a
range check when accessing a value is needed.
Point taken, so your proposal makes sense...
Michael.
_______________________________________________
fpc-devel maillist - fpc-devel@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel