More Wish List
- Posted by "Cuny, David at DSS" <David.Cuny at DSS.CA.GOV> Sep 29, 2000
- 425 views
Here's a wish for the 'while' and 'for' loops: [for loop] for <var> = <start> to <end> [by <step>] do [exit] [continue] [else <statements>] end for [while loop] while <test> do <statements> [exit] [continue] [else <statements>] end while [continue] This instruction causes the code to jump to the top of the loop. It's standard with most languages, and always puzzled me that Euphoria hasn't got one yet. [else] I found this one in Python, and it's pretty cool. If the loop is exited *without* encountering an 'exit' statement, the 'else' branch is taken. So instead of having to write this sort of thing to handle exceptions: integer found found = False for i = 1 to length( s ) do ... code goes here ... if test then flag = True exit end if end for if not found then ... exception processing ... end if you could use the 'else' to handle the exception: for i = 1 to length( s ) do ... code goes here ... if test then exit end if else ... exception processing ... end for It not only makes the code shorter, but it binds the exception code to the loop construct, which is where it logically belongs. -- David Cuny