Re: feature request : for

new topic     » goto parent     » topic index » view thread      » older message » newer message
DerekParnell said...
Kat said...

I have been duplicating loops when i need only one, if the following were possible:

Something like this has been suggested but with different syntax to avoid accidental coding mistakes ...

for dirloop = 'A' to 'Z' do -- existing syntax 
 
---- vs ---- 
 
for dirloop = {0..9,A..Z,a..z} do -- my suggestion  
 
---- vs ---- 
 
for each dirloop in {0..9,A..Z,a..z} do -- your suggestion 

This construct could also lead to some better optimised intermediate code in some circumstances.


I don't think "for each" flows off the tongue easily, and i don't see how a coding mistake could be made in that example. It's merely specifying a start and end, and a list of in-between alternatives to incrementing a counter of integers. It also introduces no new keywords or syntax (really). The loop processes each value in the range in each case, adding the words "each" to the new form confuses me, because it could just as validly be applied to the current syntax. Adding "each" would negate the use of the "continue" keyword or the current "by delta" syntax.

Please elaborate your points to show me why adding "each" is a good idea.

useless

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu