Re: Open Source
- Posted by Andy Drummond <andy at kestre??ele.com> Oct 22, 2007
- 607 views
Jason Gade wrote: > > I also like the idea of "continue <label>" or "next <label>" where label > is an optional identifier at the beginning of a loop. But I haven't given it > too > much thought. > I would like to suggest three additions to the syntax of Euphoria which would get around 99% of the desire for a goto. Nothing new but as suggested above: next var -- Go to the iteration point of the for loop for this variable exit var -- Ditto but exit the loop redo var -- Ditto but re-run the loop without iterating the variable For nested loops the interpreter would have to release variables which were out of scope, but that is simple enough. If you have three nested loops using I, J & K, say, and in the middle had "next I", then that would be coded as exit K; exit J; next I;
for i=1 to 10 do for j=1 to 10 do for k=1 to 10 do if some condition met then next i -- effectively: exit k -- exit j -- next i end if end for end for end for
These three would make the nested loop control much easier to code and much easier to read. And the desire for goto would almost vanish. Most people who ask for goto statements want them for exiting nested loops, it seems to me. Any suggestions? Anyone able to add these to the interpreter? Andy Drummond