Re: voting on GOTO
- Posted by Bernie Ryan <xotron at bl?e?rog.com> Jun 04, 2008
- 804 views
Jim Brown wrote: > > Ok, so here is the official voting thread for the proposal on goto and label. > > My proposal was basically a goto that was restricted to using only labels in > > the current scope, but otherwise unrestricted. > > Please vote yes or no, or abstain. Comments appreciated. > > The full details of the proposal as currently slated, are: > > goto and labels are only valid in the current scope. You can use the keyword > goto to > jump around in the same file at top level scope (but not across files, > > only within the same file) and you can use goto to jump around inside > > routines. But you can't jump across scope. Goto can't see labels that > > are outside of the current local scope, and there is no support for a > > 'global' scope. The current local scope will either be the top-level > > scope of the file code is currently executing from, or the private scope > > of the routine that goto is executing inside of. > > Labels are defined with the label keyword, and are strings. You can define > and use labels in the top-level scope of a file, but this is discouraged. > > > Scoping isn't affected by loops. This includes for loops. Any other type > > of loop, jumping in and out works as you expect it would. > > You can just backwards and forwards. Labels do not have to come before goto > statements or vice versa. > > > For for loops, jumping out doesn't appear to cause any problems. Jumping > > into a for loop leaves the loop variable uninitialized, which can cause > > problems if you allow execution to reach the end of the for loop. (If > > you dont read the loop var and you jump back out of the for loop, then > > it works fine. If you only jump around theinside of a for loop but allow > > the for loop to start iteration normally, then it also works fine. > > Likewise if you jump to a label that is right before the start of a for > > loop.) > > > It is possible to check if a variable is uninitialized. The recommended way > to deal with for loops is, if you must jump into a for loop, check if the > variable > is uninitialized and jump to a label that is right before the the beginning > of the for loop statement to continue iteration. > Jumping into for loops is discouraged, however. I vote No; would rather see forward reference instead of goto. Bernie My files in archive: WMOTOR, XMOTOR, W32ENGIN, MIXEDLIB, EU_ENGIN, WIN32ERU, WIN32API Can be downloaded here: http://www.rapideuphoria.com/cgi-bin/asearch.exu?dos=on&win=on&lnx=on&gen=on&keywords=bernie+ryan