[fpc-devel] Re: Testing for..in feature

Paul Ishenin ip at kmiac.ru
Thu Nov 5 04:53:43 CET 2009

Florian Klaempfl wrote:
> You can use the rtti generated for those enums.

Actually I can't :)

type T = (a1, b1=5);
   ch: T;
   Info: PTypeInfo;
   Info := TypeInfo(T);

compiler: project1.lpr(10,11) Error: No type info available for this type

So what is the best solution for now:

1) check if enum has jumps and give an error
2) skip any compiler code modifications since the next code still works 
and outputs 5 numbers:
type T = (a1, b1=5);
   ch: T;
   for ch in T do
     WriteLn(Ord(ch)); // <- note Ord() here
3) fix write/writeln to write something for the non-existent enum 
members (in the example they are 2, 3, 4) instead of giving runtime error
4) write 2 magic functions: one to get the next enum value, one to get 
the previos enum value and implement a special handling in the for-in 
loop for such arrays

Best regards,
Paul Ishenin.

More information about the fpc-devel mailing list