Jump anywhere: Difference between revisions

Added XPL0 example.
(Jump anywhere en Yabasic)
(Added XPL0 example.)
Line 2:
[[Imperative programming|Imperative programs]] like to jump around, but some languages restrict these jumps. Many structured languages restrict their [[conditional structures]] and [[loops]] to ''local jumps'' within a function. Some assembly languages limit certain jumps or branches to a small range.
 
This task is to demonstrate a local jump and a global jump and the various other types of jumps that the language supports.
For the purpose of this task, the jumps need not be used for a single purpose and you have the freedom to use these jumps for different purposes.
You may also defer to more specific tasks, like [[Exceptions]] or [[Generator]].
Line 2,887:
[./jump line 17] in new(_) block argument
</pre>
 
=={{header|XPL0}}==
XPL0 has no goto statement. The closest statements are 'return' 'exit'
and 'quit', the latter being used to jump out of a 'loop' from anywhere.
 
The 'return' command is implied at the end of a procedure, but when
explicitly written, it returns to the caller from anywhere (and from a
function it returns a value).
 
Of course there are implied jumps in 'if' statements and in all the
looping statements.
 
An unusual feature is the Restart intrinsic. This is like the 'exit'
statement, but it restarts the program. It's sometimes simpler to restart
than to unwind nested procedure calls, if for instance an error is
detected.
 
Certain errors, such as divide-by-zero, can cause a program to exit
(unless disabled by the Trap intrinsic).
 
If a 'jump anywhere' must be done, inline assembly code is available.
 
=={{header|Yabasic}}==
772

edits