Re: Exiting multiple loop constructs
Derek Parnell wrote:
>
> I reject the 'numbered' loop approach due to the added work it requires during
> maintenance.
I agree. Just including them all
> In short ...
> ... 'exit' should mean EXIT FROM the (named) loop.
>
> ... 'next' should mean begin the NEXT iteration of the (named) loop.
>
> ... 'retry' should mean RETRY the same iteration of the (named) loop.
>
Yes, that makes better sense (although I am still in favor of continue instead
of next, but that's another discussion that has not yet finished
).
>
> > Should any syntax change to support exiting multiple loops?
>
> Huh? Do you mean ... <snip>
I mean, do we need to make this change or is the current multiple
check/condition that exists in Euphoria right now OK for loops.
>
> 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?
The label keyword I think, unless Rob or Matt has a better idea, pretty
important because it fits the idea of how the parser works. For instance, I can
say in the parsing code:
tok = next_token()
if tok[T_ID] = LABEL then
loop_label = StringToken()
else
putback(tok)
end if
I am not sure how an unidentified label would fit into the parsing scheme. The
thing is for certain that we want *optional* labels. I could easily parse:
while 1 :top: do
--- or ---
while 1 @top do
--- or any other thing ---
if a label was required, but we absolutely do not want to require a label. Now
bear in mind, that when you load the source in your editor (if it does syntax
highlighting) that it the keyword label will highlight just as an optional "by"
keyword highlights in a for loop:
for i = 1 to 10 by 2 do
If your editor is nice enough, it may even be able to make the word after the
label bright flashing red, green and blue colors for you
> }}}
<eucode>
> @top while 1 do
> @mid for i = 1 to 10 do
> @bottom for j = 1 to 10 do
> </eucode>
{{{
Syntax parsing would have to change to make this work, I do not think that's
somewhere I want to venture due to understanding of the parser still. If
something like that is the final decision, then Matt or Rob will have to step in.
However, I must say, that I personally think it's very distracting. The key to
those lines is not what the label is, it is the fact they are a while, for and
for loop. But with the @top, @mid, @bottom, the "while", "for" and "for" are then
lost. I think the labels are secondary to the function that's being performed.
--
Jeremy Cowgar
http://jeremy.cowgar.com
|
Not Categorized, Please Help
|
|