Re: Exiting multiple loop constructs
Jason Gade wrote:
>
> I agree that maybe the label should be before the loop, but I really don't
> like
> the punctuation in place of a keyword. I find the word label far easier to
> read
> than a decorating symbol, too many of which end up looking like line noise.
>
> Maybe crib from other languages again?
>
> }}}
<eucode>
> label outer: while count < last_item do
> label inner: -- can also appear on its own line
> for i = 1 to length(stuff) do
> if stuff[i] = BADVALUE then exit outer -- leaves both loops
> elsif stuff[i] > LIMIT then continue inner -- goes to next
> iteration
> else mung(stuff[i])
> end if
> end for
> end while
> </eucode>
{{{
>
Here again, I think this takes away from the purpose and makes code *very* hard
to read and understand. label is an optional parameter for a while/for keyword.
The while and for keywords are the important part of the line. The label is 100%
secondary. Also, the above syntax and one proposed by Derek would make you think
you could:
@again if 1 = 20 then
Which you cannot.
for a = 1 to length(lines) by 2 label top do
end for
is clear, understandable, readable and not confusing the matter that the for
loop is labeled TOP.
Now, if you want to make it stand out, use syntax highlighting or make it all
caps?
for a = 1 to length(lines) by 2 label TOP do
end for
--
Jeremy Cowgar
http://jeremy.cowgar.com
|
Not Categorized, Please Help
|
|