[fpc-devel] [Suggestion] Enumeration range-check intrinsic

Sven Barth pascaldragon at googlemail.com
Fri Jul 5 14:29:15 CEST 2019


J. Gareth Moreton <gareth at moreton-family.com> schrieb am Fr., 5. Juli 2019,
14:02:

> I'm glad we agree on the "is" operator.  Personally I would like to
> extend it so it accepts "if (I is TMyEnum) then" when I is also of type
> TMyEnum, since it may be the case that you're reading I directly from a
> stream, either individually or as part of a record, in which case
> converting I from an Integer to TMyEnum is a little inconvenient.  When
> you get down to the compiled assembly language it shouldn't really
> matter anyway.
>

It might not matter from the assembly point of view, but it matters from
the language point of view. When we say that enum values only contain valid
values then "myenum is TMyEnum" *must* always evaluate to true, because
otherwise there's an exception of the rule that enums only contain valid
values.

Regards,
Sven

>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-devel/attachments/20190705/236f7e4a/attachment.html>


More information about the fpc-devel mailing list