[fpc-devel] [Suggestion] Enumeration range-check intrinsic
Ondrej Pokorny
lazarus at kluug.net
Mon Jul 8 13:48:39 CEST 2019
On 08.07.2019 12:39, Giuliano Colla wrote:
> Il 07/07/2019 07:33, J. Gareth Moreton ha scritto:
>> In the meantime, I'm working on making
>> "as" and "is" work with ordinal types as
>> well as enumerations, although currently
>> some headaches occur if the right-hand
>> side is larger than the CPU word size
>> (e.g. Int64 on i386). I'll upload the
>> patch to the issue once it's working
>> properly.
>
> Sorry for jumping in without having followed the full discussion, but
> I wonder if "as" and "is" are the best constructs to implement range
> checking. Wouldn't "in" be much more appropriate?
>
> Sort of:
>
> if value in enumvar then DoThat else IgnoreIt;
The IN operator
1.) expects a value on the right side, not a type.
2.) can be overloaded:
https://www.freepascal.org/docs-html/ref/refse104.html#x213-23500015.6 .
IS/AS cannot.
Ondrej
More information about the fpc-devel
mailing list