Re: Labeled Loops?

new topic     » goto parent     » topic index » view thread      » older message » newer message

Jason Gade wrote:
> 
> I'm not sure I'm following here.
> 
> But say it's implemented so the syntax is:
> }}}
<eucode>
> while 1 do label top
>     for i = 1 to 10 do label mid
>         ? i
>     end for
> end while
> </eucode>
{{{

>

It would be slightly different

while 1 label top do
    for i = 1 to 10 label mid do
        ? i
    end for
end while


> Where top and mid have a scope similar to "for" variables -- that is, to the
> end of their respective "end" statements and couldn't be used otherwise as
> variables.
> But they wouldn't be objects or anything. Hmm.
> 
> Maybe that's a reason to make them string or sequence constants instead?
> 
> Still kinda confused.
> 

Internally a for loop and while loop have a stack where a reference to the loop
variable is stored (for loop), the position in IL where the loop starts and ends.
A label would simply be added to that stack item associated with the loop. Thus,
the label could be considered an internal loop identifier. It has to be neither a
sequence or integer. It simply has to exist, if you give the loop a "label"
keyword.

--
Jeremy Cowgar
http://jeremy.cowgar.com

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu