Re: ver 4.0 goto ?

new topic     » goto parent     » topic index » view thread      » older message » newer message
bernie said...
CChris said...
bernie said...
bernie said...

In the documents there is no explanation or examples  
of how to use goto and exactly where it can be used. 
 
quoting the manual:  
"The following flow control keywords are available." 
 
"break retry entry exit continue return goto end" 
 
Where is it used ( in which flow control statement ? ) and how is it used ? 

64 user's have read this post but nobody has responded to it.

goto can be used anywhere, at your own risks. Its target is limited to the current routine, or the current file if outside any routine.

Syntax is:

goto "label string" 

where a label is defined by the

label "label strng" 

statement.

Header labels do not count as possible goto llabel targets.

Use goto in production code when amllthe following applies:

  • You want to proceed with a statement which is not the followin one;
  • the various structured constructs wouldn't do, or very awkwardl;
  • you contemplate a significant gain in speed/reliability;
  • the code flow remains understandable for an outsider.

Otherwise, at early development, it may be nice to have while the code isn't firmly structured. But most instances of it should melt into structured constructs as soon as possible.

I am aware of at least two sorts of use for it:

  • A routine has several return statements, and some processing must be done before returning, no matter from where. It may be clearer to goto a single return point and perform the processing only at this point.
  • An exit statement in a loop corresponds to an early exxit, and the normal pocessing that immediately follows the loop is not relevant. Replacing an exit statement followed by various flag testing by a single goto can help.

Explicit label names will tremendously help maintenance.

If gotoing into a scope (an if block, a for loop,...) will just do that. Some variables may be defined only in that scope, and they may or may not have sensible values. As mentioned above, it is at your own risk.

CChris

Thank You for the information.

I recommend that your description be added to the manual.

Me too.

bernie said...
CChris said...
bernie said...
bernie said...

In the documents there is no explanation or examples  
of how to use goto and exactly where it can be used. 
 
quoting the manual:  
"The following flow control keywords are available." 
 
"break retry entry exit continue return goto end" 
 
Where is it used ( in which flow control statement ? ) and how is it used ? 

64 user's have read this post but nobody has responded to it.

goto can be used anywhere, at your own risks. Its target is limited to the current routine, or the current file if outside any routine.

Syntax is:

goto "label string" 

where a label is defined by the

label "label strng" 

statement.

Header labels do not count as possible goto llabel targets.

Use goto in production code when amllthe following applies:

  • You want to proceed with a statement which is not the followin one;
  • the various structured constructs wouldn't do, or very awkwardl;
  • you contemplate a significant gain in speed/reliability;
  • the code flow remains understandable for an outsider.

Otherwise, at early development, it may be nice to have while the code isn't firmly structured. But most instances of it should melt into structured constructs as soon as possible.

I am aware of at least two sorts of use for it:

  • A routine has several return statements, and some processing must be done before returning, no matter from where. It may be clearer to goto a single return point and perform the processing only at this point.
  • An exit statement in a loop corresponds to an early exxit, and the normal pocessing that immediately follows the loop is not relevant. Replacing an exit statement followed by various flag testing by a single goto can help.

Explicit label names will tremendously help maintenance.

If gotoing into a scope (an if block, a for loop,...) will just do that. Some variables may be defined only in that scope, and they may or may not have sensible values. As mentioned above, it is at your own risk.

CChris

Thank You for the information.

I recommend that your description be added to the manual.

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

Search



Quick Links

User menu

Not signed in.

Misc Menu