Am 25.01.2013 17:18, schrieb Alexander Klenin: > On Fri, Jan 25, 2013 at 7:07 PM, Michael Van Canneyt > <mich...@freepascal.org> wrote: >> WITH EACH ADDITIONAL "FEATURE" WE ARE BUTCHERING PASCAL MORE AND MORE. > Hm... Do not you think this is a bit of an overstatement? > >> There are plenty to choose from. He said maybe he'd look after fcl-stl. The >> silence since was deafening. > "for-in-index" extension was actually planned by me as a prerequisite > for fcl-stl work.
Using indicies is against all principles of iterators. > I did some experiments with the current implementation, even discussed > it at a conference > related to teaching of algorithmic programming to children. > As I have already explained, main competition in this area now comes > from Python and > other dynamic languages. While discussing container access in Pascal vs > Python, > lack of "for-in-index" was brought up by attendees as one of Pascal's > weaknesses. The idea of iterators is actually to replace and get rid of indicies because they e.g. fail as soon as the iterated container is changed during iteration. Depending on the iterated container, iterators might be still valid even if the container changes. > var > a: array [1..5] of Integer = (1, 2, 9, 4, 5); > > In my proposal, he should write: > var > v, i: Integer; > begin > for a in a index i do > Writeln(i, ' ', v); > end. In this case I just write for i:=low(a) to high(a) do writeln(i,' ',a[i]); Works afaik since TP 6.0. _______________________________________________ fpc-devel maillist - fpc-devel@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-devel