rE: Language Design

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

On 28 May 2004, at 14:34, Christian Cuvier wrote:

> 
> 
>  In my idEu project, I stopped coding while debugging the implementation of=
>  goto.
> Quite a hell really. Since I now contribute at an unexpectedly high level t= o
> the OpenEuphoria project, this code is just sitting on the HD, waiting either
> for OE or EU w= ith useful features to start flying.
>  goto is not improper by itself, since all asm code use it without any othe= r
> alternative left. But it is probably too tricky to implement and leads too
> easily to unmanageable/unmaintainable code, compared with its usefulness.

It's actually easy to make it happen if you follow the example of Turbo 
Pascal: each and every loop is an external call, and goto is treated like an 
exit until the target is found. In this way, each nested loop in the path to the
target is allowed to clean up after itself normally, and since RobC already 
added the exit code, a goto is trivial to add. The compiled code all sees it as 
a single-level exit, that just keeps exiting until the target is found.
Ironically, if
there is no target found, a line like "goto end" would simply fall thru to the 
bottom of the procedure it's in and the procedure would return normally, 
returning to normal program flow with no errors (unless you add error code).

 And if you have multiple ":next" targets, "goto next" would stop exiting at 
the first ":next" it hits, if you want a general purpose x-level exit command 
like that:

for loop = 1 to whatever do
  while blah do 
    if this then
        -- code
     if blahblah then goto next end if
        -- more code
    end if
    :next

  end while
  :next

end for
:next

Same goto gets you all your loop exits. Lets make it exciting, and allow 
wildmatches in exit targets! So "goto next*" matches ":next1" and ":next2"!

Kat

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

Search



Quick Links

User menu

Not signed in.

Misc Menu