Skip to content

Commit

Permalink
docs: document multi-level break, continue
Browse files Browse the repository at this point in the history
Signed-off-by: Steve Bennett <steveb@workware.net.au>
  • Loading branch information
msteveb committed May 13, 2023
1 parent b053638 commit dc4ef51
Showing 1 changed file with 26 additions and 5 deletions.
31 changes: 26 additions & 5 deletions jim_tcl.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Jim Tcl(n)

NAME
----
Jim Tcl v0.82 - reference manual for the Jim Tcl scripting language
Jim Tcl v0.82+ - reference manual for the Jim Tcl scripting language

SYNOPSIS
--------
Expand Down Expand Up @@ -52,6 +52,10 @@ Some notable differences with Tcl 8.5/8.6/8.7 are:

RECENT CHANGES
--------------
Changes since 0.82
~~~~~~~~~~~~~~~~~~
1. Multi-level `break` and `continue` are now supported

Changes between 0.81 and 0.82
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1. `try` now supports trap to match on errorcode
Expand Down Expand Up @@ -1882,12 +1886,26 @@ command. The legal +'options'+ (which may be abbreviated) are:

break
~~~~~
+*break*+
+*break* ?n?+

This command may be invoked only inside the body of a loop command
such as `for` or `foreach` or `while`. It returns a +JIM_BREAK+ code
such as `for`, `foreach`, `while` or `loop`. It returns a +JIM_BREAK+ code
to signal the innermost containing loop command to return immediately.

If +'n'+ is given it breaks out of that many loops. +'break 1'+ is equivalent
to a simple +'break'+ while in the following example, +'break'+ will exit both
loops.

----
loop i 5 {
loop j 6 {
if {$i == 3 && $j == 2} {
break 2
}
}
}
----

case
~~~~
The obsolete '+*case*+' command has been removed from Jim Tcl since v0.75.
Expand Down Expand Up @@ -2032,13 +2050,16 @@ as its result.

continue
~~~~~~~~
+*continue*+
+*continue* ?n?+

This command may be invoked only inside the body of a loop command such
as `for` or `foreach` or `while`. It returns a +JIM_CONTINUE+ code to
as `for`, `foreach`, `while` or `loop`. It returns a +JIM_CONTINUE+ code to
signal the innermost containing loop command to skip the remainder of
the loop's body but continue with the next iteration of the loop.

If +'n'+ is given it breaks out of +'n-1'+ loops and then continues the +'nth'+ loop.
+'continue 1'+ is equivalent to a simple +'continue'+. (See also `break`).

curry
~~~~~
+*alias* 'args\...'+
Expand Down

0 comments on commit dc4ef51

Please sign in to comment.