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

Alexander Klenin klenin at gmail.com
Thu Nov 5 05:34:49 CET 2009

On Thu, Nov 5, 2009 at 13:53, Paul Ishenin <ip at kmiac.ru> wrote:
> So what is the best solution for now:
> 1) check if enum has jumps and give an error

This is what Succ/Pred do currently. I think that if we decide _not_
to choose option (1), current Succ/Prev behaviour should be considered an error.

> 2) skip any compiler code modifications since the next code still works and
> outputs 5 numbers:
> type T = (a1, b1=5);
> var
>  ch: T;
> begin
>  for ch in T do
>    WriteLn(Ord(ch)); // <- note Ord() here
> end

What are these numbers? (Sorry, I am at work, can not test from here).
I would be surprised if they are "0 5".

> 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

No, I think runtime error is correct here.

> 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

I always thought Succ/Pred are exactly such magic functions ;-)

Alexander S. Klenin

More information about the fpc-devel mailing list