-
Notifications
You must be signed in to change notification settings - Fork 2
_goto
abinition edited this page Oct 22, 2014
·
6 revisions
#goto
###Branch (go) to a label.
Syntax
goto label ;
Arguments
- list label
A 'variable' label, defined elsewhere in the program as 'label :'
Exceptions
-
%ARGUMENT: Invalid arguments. Usage: goto label ;
-
%IDENTIFIER: 'variable' argument is not a valid identifier, literal, or reference
Description
A label is like a hashtag, in marks a position in the program. A label should not be confused with a namespace in a variable, eg: xs:schema.
Examples
int i = 0 ;
label :
if ( i == 0 ) {
// First pass:
// A label is actually a variable, defined as ""
puts { "First pass, label = ",label };
}
else if ( i == 1 ) {
// Second pass, after using 'goto'
puts { "Second pass, label = ",label } ;
}
else if ( i == 2 ) {
// Third pass, exit
puts { "Third pass, we exit" } ;
exit ;
}
i++ ;
// A label's value can be reassigned, it doesn't affect it as a label
label = "whatever" ;
goto label ;
Related Links