[fpc-devel] "case" with range stupidities

Vinzent Hoefler JeLlyFish.software at gmx.net
Thu Feb 15 13:58:16 CET 2007


Hi all,

consider the following program:

-- 8< --

program
   Case_Test;

type
   My_Range = 2000 .. 3000;

var
   X : Integer;

begin
   X := 2500;

   case X of
      Low (My_Range) .. High (My_Range) : WriteLn ('In range. (1)');
      My_Range                          : WriteLn ('In range. (2)');
   else
      WriteLn ('Out of range.');
   end {case};
end {Case_Test}.

-- 8< --

Is there any reasoning why the first switch in the case statement ("Low 
(My_Range) ...") is allowed, whilst the second one (just "My_Range") is 
not (says: "constant expression expected")?


Another minor issue is that a type declaration like:

   type
      My_Range = (2500 - 500) .. (2500 + 500);

is not accepted (message similar to ";" expected, ".." found) and 
(basically the same declaration)

   type
      My_Range = 2500 - 500 .. 2500 + 500;

is. Sometimes I'd really like to add those parantheses just to make the 
intention more clear.


Regards,

Vinzent.




More information about the fpc-devel mailing list