Script substitution

Script Substitution is the more apt term for Command Substitution, since entire scripts, not just individual commands, can be contained in brackets. The result of the script is the result of the final command. A new stack frame is not created, so using return or break or the like will cause the caller to return, etc.

Recursion

PYK 2019-02-12: Script substitution can be recursive. Everything happens at the same level, as no additional levles are created:

puts [
    set n 10
    set a {
        puts $n
        expr {[incr n -1]? [try $a] : {liftoff}}
    }
    try $a
]

Comments

AMG: Script substitution can be used in combination with list and {*} to embed comments in lists. The syntax is awkward, but it does work:

switch -regexp $input [list {*}[
# Handle words starting with a capital letter
] {^[A-Z]} {
    # Do the thing
    theThing
} {*}[
# Handle everything else
] default {
    # Don't do the thing
}]

Though also consider using decomment for this same purpose.