Re: Euphoria features
- Posted by Everett Williams <rett at GVTC.COM> Nov 15, 1999
- 520 views
On Mon, 15 Nov 1999 11:17:37 -0800, Cuny, David at DSS <David.Cuny at DSS.CA.GOV> wrote: >Everett Williams writes: > >> In addition, nobody has addressed my question >> about the scoping effects of gotos. > >I'd assume the following constraints: > >1. GOTOs limited to the same routine. I arbitrarily disallow in-line GOTOs. > >2. Only forward GOTOs: > > foo: > -- NOT ALLOWED > goto foo: > >3. You can leap out of block structures: > > for i = 1 to 10 > for j = 1 to 10 > if x = 12 then > goto label: > end if > end for > label: > end for Did I miss something...exit can accomplish this one. If I may borrow your example. for i = 1 to 10 for j = 1 to 10 if x = 12 then goto label: end if end for ... procx() ... label: end for Exit cannot accomplish this. So can this. for i = 1 to 10 for j = 1 to 10 if x = 12 then exit end if end for if x != 12 then ... procx() ... end if end for It is explicit and costs one more line of code. OR skip1 = true for i = 1 to 10 for j = 1 to 10 if x = 12 then skip1 = false exit end if end for while skip1 do ... procx() ... skip1 = false end while end for This has the advantage of explicitly describing the range of code to be skipped and the variable name tells you the purpose of the while(along with any comments you might have). The goto allows code to be inadvertently added in the area skipped by the goto with little indication that it may not be executed at the exit to the for. I also allows selective skipping. More lines of code that clearly document intent and create very little extra overhead if I understand what is likely to have to be done when a goto is encountered. >4. You can leap into block structures: > > goto label: > for i = 1 to 10 do > -- NOT ALLOWED > label: Agreed, this is a real non-starter. >Seems to me that this allows the goal of leaping out of blocks of logic. > >-- David Cuny For your perusal. Everett L.(Rett) Williams rett at gvtc.com