[fpc-devel] Dangerous optimization in CASE..OF

Thorsten Engler thorsten.engler at gmx.net
Sat Apr 14 11:51:48 CEST 2018


I haven't checked out the changes you made to the compiler, so you might have already covered this, but while you are at it, you might want to just make this work for any ordinal type with a well-defined upper/lower bound (any type for which High()/Low() can be evaluated at compile time). So:

type
  TSubRange=-5..5;
  TEnum=(One, Two);

var
  i: Int64;

begin
  if i is TSubRange then
    //...
  If i is TEnum then
    //...
  If i is SmallInt then
    //...

(same with "as").



> -----Original Message-----
> From: fpc-devel <fpc-devel-bounces at lists.freepascal.org> On Behalf
> Of Ondrej Pokorny
> Sent: Saturday, 14 April 2018 19:03
> To: fpc-devel at lists.freepascal.org
> Subject: Re: [fpc-devel] Dangerous optimization in CASE..OF
> 
> On 14.04.2018 10:39, Thorsten Engler wrote:
> > How about following the same schema as with classes?
> >
> > If 1 is TMyEnum then
> >    //use hard cast here
> 
> Yes, that is reasonable as well and it will be easier to implement
> than the TryIntToEnum/IntToEnum intrinsics for me.
> 
> Ondrej
> _______________________________________________
> fpc-devel maillist  -  fpc-devel at lists.freepascal.org
> http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel




More information about the fpc-devel mailing list