[fpc-pascal] for..in loops?

Florian Klaempfl florian at freepascal.org
Sun Nov 20 12:13:23 CET 2005


Moz wrote:

> Micha Nelissen said:
> 
>>FPC will never support this, AFAIK. It doesn't really add anything new, it
>>just shortens the code somewhat. Only in toy examples is it nice,
> 
> 
> Could you expand this answer to cover the reasons why people might use
> Pascal rather than assembly language? Your argument seems to advocate
> using the lowest level language available...

foreach ... in ... do adds no additional abstraction layer. I consider 
foreach usefull if it allows to create own iterators which are as fast 
as walking a linked list with p:=p^.next; Especially since it then 
allows e.g. to write iterators with data prefetching.

Foreach makes even the intuitive understanding of the code harder 
because it misses the information if the iterator is random or ordered. 
I think when I'll ever implement foeach ... in ... I'll translate it to
for ...:=high... downto low... do I guess a lot of code while crash 
because people think foreach is increasing ;)

> 
> I'm a big fan of compact code and language features that promote it.

Every new language features makes it harder to learn a language and to 
read the code.

> Give me "StringList.SaveToFile()" any day over the laborious code
> that starts "var F:TextFile;"

That already ambigious, the method should be called 
StringList.SaveToTextFile()

> 
> Moz
> 
> _______________________________________________
> fpc-pascal maillist  -  fpc-pascal at lists.freepascal.org
> http://lists.freepascal.org/mailman/listinfo/fpc-pascal
> 




More information about the fpc-pascal mailing list