Re: Exiting multiple loop constructs
Gah, I missed that. I agree, Derek, that it should be exit from, not exit to.
Derek Parnell wrote:
> I'm thinking that the 'label' syntax is just too easy to overlook as it makes
> the code seem cluttered. Maybe using some punctuation might help make it stand
> out?
>
> }}}
<eucode>
> while 1 :top: do
> for i = 1 to 10 :mid: do
> for j = 1 to 10 :bottom: do
> </eucode>
{{{
>
> }}}
<eucode>
> while 1 @top do
> for i = 1 to 10 @mid do
> for j = 1 to 10 @bottom do
> </eucode>
{{{
>
> I do think that the label needs to be to the left of the 'do' but maybe it can
> actually be to the left of the loop statement.
> }}}
<eucode>
> @top while 1 do
> @mid for i = 1 to 10 do
> @bottom for j = 1 to 10 do
> </eucode>
{{{
>
> because then it could be made to standout even more by placing it on its own
> line ...
>
> }}}
<eucode>
> @top
> while 1 do
> @mid
> for i = 1 to 10 do
> @bottom
> for j = 1 to 10 do
> </eucode>
{{{
>
> --
> Derek Parnell
> Melbourne, Australia
> Skype name: derek.j.parnell
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?
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
Nah, that might not work because it might not be linked to the end <loop>
statement.
What about "dolabel"?
while count < last_item dolabel outer
for i = 1 to length(stuff) dolabel inner
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
Just brainstorming.
--
A complex system that works is invariably found to have evolved from a simple
system that works.
--John Gall's 15th law of Systemantics.
"Premature optimization is the root of all evil in programming."
--C.A.R. Hoare
j.
|
Not Categorized, Please Help
|
|