break(3tcl)
π break(3tcl) β Tcl Built-In Commands
okay bestie, welcome to the break page, she's short but she is powerful, and she lives in the Tcl Built-In Commands manual. let's go π
β¨ NAME β¨
break β abort looping command. literally just "stop the loop", that's her whole job, and she ate π
πΈ SYNOPSIS πΈ
break
no args, no flags, no options, she takes nothing and she gives everything π«Ά
π¦ DESCRIPTION π¦
so the vibe is: you call break inside the body of a looping command β think for, or foreach, or while, the usual suspects. π
when you do, it returns a 3 (TCL_BREAK) result code, which causes a break exception to occur. and that exception does the thing: it causes the current script to be aborted out to the innermost containing loop command, and that loop then aborts its execution and returns normally. like, she just dips, no drama, no error message, the loop is done, moving on π
and not me telling you this but β break exceptions are also handled in a few other situations, bestie, namely:
- the
catchcommand - Tk event bindings
- the outermost scripts of procedure bodies
so it's not only loops, iykyk. the more you know β¨
π EXAMPLE π
print a line for each of the integers from 0 to 5:
for {set x 0} {$x<10} {incr x} {
if {$x > 5} {
break
}
puts "x is $x"
}
see how the loop says it'll go to 10 but break is like "no babe, we're done at 5"? main character energy fr fr π
π SEE ALSO π
π KEYWORDS π
abort, break, loop
ngl this is the whole page, there's no bugs section, no warnings, nothing scary. she's simple, she's iconic, she's break. periodt. π
that's a wrap bestie!! this was the break(3tcl) page from Tcl, version and date stamped on the original footer as Tcl / break(3tcl) β sending you love and a clean loop exit πβ¨π¦π
π¦ where this page comes from
- debian bookworm: tcl8.6-doc 8.6.13+dfsg-2
- debian trixie: tcl8.6-doc 8.6.16+dfsg-1
- debian trixie: tcl9.0-doc 9.0.1+dfsg-2
- ubuntu jammy: tcl8.6-doc 8.6.12+dfsg-1build1
- ubuntu noble: tcl8.6-doc 8.6.14+dfsg-1build1
- ubuntu questing: tcl8.6-doc 8.6.17+dfsg-1
- ubuntu questing: tcl9.0-doc 9.0.2+dfsg-1
- ubuntu resolute: tcl8.6-doc 8.6.17+dfsg-1build1
- ubuntu resolute: tcl9.0-doc 9.0.3+dfsg-1
- ubuntu stonking: tcl8.6-doc 8.6.18+dfsg-1
- ubuntu stonking: tcl9.0-doc 9.0.4+dfsg-1
- Copyright (c) 1993-1994 The Regents of the University of California
- Copyright (c) 1994-1996 Sun Microsystems, Inc
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms