1. More Wish List
- Posted by "Cuny, David at DSS" <David.Cuny at DSS.CA.GOV> Sep 29, 2000
- 426 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
2. Re: More Wish List
- Posted by "Cuny, David at DSS" <David.Cuny at DSS.CA.GOV> Sep 29, 2000
- 418 views
Derek Parnell wrote: > for i = 1 to length( s ) do > ... code goes here ... > if test1 then > exit code1 > end if > ... more code can go here ... > if test2 then > exit code2 > end if > ... more code can go here ... > when code1 > exception processing ... > when code2 > exception processing ... > end for I'm not entirely clear what's happening here. If the intent is to allow the user to jump to the bottom of the loop, run the exception processing, and exit, this will accomplish the same thing, with no new construct and the same amount of code. for i = 1 to length( s ) do ... code goes here ... if test1 then code1 exception processing exit end if ... more code can go here ... if test2 then code2 exception processing end if ... more code can go here ... end for Am I missing something? -- David Cuny
3. Re: More Wish List
- Posted by "Cuny, David at DSS" <David.Cuny at DSS.CA.GOV> Sep 29, 2000
- 406 views
Derek Parnell wrote: > How about ... OK, I'm clear on it now. -- David Cuny