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

2009-11-05 Thread Vinzent Höfler
Von: Michael Van Canneyt mich...@freepascal.org: Like I said, we should not have named it enums. They are not enums. They're a hack to support some C construct in a type-safe way. No more, no less. IBTD. -- 8 -- with Ada.Text_IO; use Ada.Text_IO; with Ada.Unchecked_Conversion; procedure

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

2009-11-05 Thread Alexander Klenin
On Fri, Nov 6, 2009 at 05:51, Vinzent Höfler jellyfish.softw...@gmx.net wrote: Von: Michael Van Canneyt mich...@freepascal.org: Like I said, we should not have named it enums. They are not enums. They're a hack to support some C construct in a type-safe way. No more, no less. IBTD. [skip

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

2009-11-05 Thread Florian Klaempfl
Alexander Klenin schrieb: The best Succ(X) algorithm I can think of that works correctly on sparse enums is O(log enum_size). It depends how much memory one wastes ;) ___ fpc-devel maillist - fpc-devel@lists.freepascal.org

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

2009-11-04 Thread Paul Ishenin
Alexander Klenin wrote: Yet another bug: --- type T = (a1, b1=5); var ch: T; begin for ch in T do Writeln(ch); end. This is caused by the problem in the for-to loop: for ch := Low(T) to High(T) do WriteLn(ch) How should I solve the problem in the for-in loop? I tried the next way:

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

2009-11-04 Thread Florian Klaempfl
Paul Ishenin schrieb: Alexander Klenin wrote: Yet another bug: --- type T = (a1, b1=5); var ch: T; begin for ch in T do Writeln(ch); end. This is caused by the problem in the for-to loop: for ch := Low(T) to High(T) do WriteLn(ch) How should I solve the problem in the

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

2009-11-04 Thread Alexander Klenin
On Wed, Nov 4, 2009 at 22:36, Paul Ishenin webpi...@mail.ru wrote: Alexander Klenin wrote: Yet another bug: --- type T = (a1, b1=5); var  ch: T; begin  for ch in T do Writeln(ch); end. This is caused by the problem in the for-to loop: for ch := Low(T) to High(T) do  WriteLn(ch)

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

2009-11-04 Thread Paul Ishenin
Florian Klaempfl wrote: You can use the rtti generated for those enums. For me it is still the question if for-to loop should work: for ch := Low(T) to High(T) do WriteLn(ch) Best regards, Paul Ishenin. ___ fpc-devel maillist -

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

2009-11-04 Thread Marco van de Voort
In our previous episode, Paul Ishenin said: Yet another bug: --- {$apptype console} type T = (a1, b1=5); var ch: T; begin for ch in T do Writeln(ch); end. CodeGear Delphi for Win32 compiler version 20.0 Copyright (c) 1983,2008 CodeGear testx.dpr(6) Error: E2029 '(' expected

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

2009-11-04 Thread Vincent Snijders
Marco van de Voort schreef: In our previous episode, Paul Ishenin said: Yet another bug: --- {$apptype console} type T = (a1, b1=5); var ch: T; begin for ch in T do Writeln(ch); end. CodeGear Delphi for Win32 compiler version 20.0 Copyright (c) 1983,2008 CodeGear testx.dpr(6) Error:

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

2009-11-04 Thread Marco van de Voort
In our previous episode, Micha Nelissen said: Does it work on not sparse enums? Those are dense enums? :-) true enums. ___ fpc-devel maillist - fpc-devel@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-devel

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

2009-11-04 Thread Paul Ishenin
Vincent Snijders wrote: Since I suspected that D2009 doesn't work on sparse enums, I tried, and the above is the result. Does it work on not sparse enums? Delphi compiler does not support for-in loop for types (enums, integer, ...). This is fpc extension :) Best regards, Paul Ishenin.

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

2009-11-04 Thread Marco van de Voort
In our previous episode, Vincent Snijders said: yy end. CodeGear Delphi for Win32 compiler version 20.0 Copyright (c) 1983,2008 CodeGear testx.dpr(6) Error: E2029 '(' expected but 'DO' found testx.dpr(7) Error: E2430 for-in statement cannot operate on collection type 'T'

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

2009-11-04 Thread Marco van de Voort
In our previous episode, Paul Ishenin said: Since I suspected that D2009 doesn't work on sparse enums, I tried, and the above is the result. Does it work on not sparse enums? Delphi compiler does not support for-in loop for types (enums, integer, ...). This is fpc extension :) Do

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

2009-11-04 Thread Paul Ishenin
Marco van de Voort wrote: Do you have unit tests for multidimensional arrays. I saw quite funky examples (involving dummy variables) in the D2009 help for that. No. I know delphi allows to enumerate multidimensional arrays but fpc traverses only the first dimension. Best regards, Paul

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

2009-11-04 Thread Marco van de Voort
In our previous episode, Alexander Klenin said: ? WriteLn(ch); ? inc(ch); But it fails the same way. ch := succ(ch); OTOH, I am not sure -- obviously either Succ or Inc is buggy, but which one? Maybe runtime instead of compile-time error is actually correct? Sparse enums are simply

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

2009-11-04 Thread Matt Emson
Marco van de Voort wrote: Sparse enums are simply a kludge. They were needed because they exist in the Windows API, and afaik for that only. IOW for easy translation of Windows types. They were added to Delphi in version 6. I though they added them to support Qt and the CLX, which relied

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

2009-11-04 Thread Marco van de Voort
In our previous episode, Matt Emson said: Sparse enums are simply a kludge. They were needed because they exist in the Windows API, and afaik for that only. IOW for easy translation of Windows types. They were added to Delphi in version 6. I though they added them to support Qt and

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

2009-11-04 Thread Paul Ishenin
Paul Ishenin wrote: Marco van de Voort wrote: Do you have unit tests for multidimensional arrays. I saw quite funky examples (involving dummy variables) in the D2009 help for that. No. I know delphi allows to enumerate multidimensional arrays but fpc traverses only the first dimension. To

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

2009-11-04 Thread Vinzent Höfler
Matt Emson memson.li...@googlemail.com: The problem I always had with Pascal supporting them was that a Pascal enum was designed to represents the position in a sequence and not necessarily an underlying integral value - where as a sparse enum is simply a grouping for a bunch of numerical

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

2009-11-03 Thread Alexander Klenin
Another minor problem: -- begin for ch in S do Writeln(ch); end. -- Results in: t.pp(2,10) Error: Identifier not found ch t.pp(2,15) Error: Identifier not found S t.pp(2,28) Error: Identifier not found ch t.pp(2,29) Error: Can not find an enumerator for the type erroneous type IMHO the last

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

2009-11-03 Thread Alexander Klenin
Yet another bug: --- type T = (a1, b1=5); var ch: T; begin for ch in T do Writeln(ch); end. --- This leads to runtime error. Note that --- type T = (a1, b1=5); begin Writeln(Succ(a1)); end. --- leads to compile-time error (although I think it should work, but that is a separate topic).

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

2009-11-03 Thread Alexander Klenin
Another bug: --- var ch: Char; begin for ch in [] do Writeln(ch); end. --- = AV in compiler -- Alexander S. Klenin ___ fpc-devel maillist - fpc-devel@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-devel