Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-devel / 2018-04

AS/IS operators for enums

1 message · 1 person ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Ondrej Pokorny

I uploaded a new patch to add enum support to AS/IS operators to https://bugs.freepascal.org/view.php?id=33603

1.) I added support for the IS operator.
2.) I added support of any ordinal type (int/enum) on the left side of
the operator:
var
   E: TMyEnum;
begin
   E := E as TMyEnum; // check if E is valid value
   if E is TMyEnum then // check if E is valid value

3.) I added support for compile-time constant evaluation as Sven suggested.

4.) I uploaded new test case projects for both AS and IS operators.

---

I did not add support to any integer type on the right side: if I is Byte then // not supported

because the boundaries of int64 and uint64 types make the whole story too complicated for me and I don't need it. If anybody wants this feature, feel free to implement it yourself.

Ondrej

Reply by email