itclvars(n)
π itclvars(n) β the [incr Tcl] variable lore, explained bestie-to-bestie π
okay so this page is itclvars, from the [incr Tcl] manual, and it's literally just about the β¨global variablesβ¨ that [incr Tcl] makes for you. short page, big vibes. let's get into it π«Ά
πΈ NAME πΈ
itclvars β variables used by [incr Tcl]
no cap, that's the whole name section. iconic brevity. π
β¨ DESCRIPTION β¨
so here's the tea: the following global variables are created and managed automatically by the [incr Tcl] library. and unless it says otherwise down below, you (and your application-specific code) should treat them as read-only. they're not yours to poke at, bestie, they're the library's. π
itcl::libraryβ when an interpreter gets created,[incr Tcl]sets this one up to hold the name of a directory that contains the system library of[incr Tcl]scripts. the initial value comes from theITCL_LIBRARYenvironment variable if that exists, and if it doesn't, it comes from a compiled-in value instead.itcl::patchLevelβ again, when an interpreter is created,[incr Tcl]initializes this to hold the current patch level for[incr Tcl]. for example, a value of"2.0p1"means[incr Tcl]version 2.0 with the first set of patches applied. so like,p1= patch drop #1, she's been updated. πitcl::puristβ okay this one is the main character of the page, ngl. when an interpreter is created containing Tcl/Tk and the[incr Tcl]namespace facility, this variable controls a "backward-compatibility" mode for widget access. let me explain, because this is the whole plot. π
in vanilla Tcl/Tk there's a single pool of commands, so the access command for a widget is the same as the window name. simple. one pool, one name, no drama.
but the moment a widget gets created within a namespace? its access command gets installed in that namespace, and from outside the namespace you're supposed to reach it with a qualified name. like so:
namespace foo {
namespace bar {
button .b -text "Testing"
}
}
foo::bar::.b configure -background red
pack .b
note that the window name ".b" is still what you use with commands like pack and destroy. but the access command for the widget β i.e. the name that shows up as the first argument on a command line β has to be more specific than that. two different things, don't mix them up bestie π
the "winfo command" command can be used to query the fully-qualified access command for any widget, so you can write:
[winfo command .b] configure -background red
and honestly? that's good practice when you're writing library procedures. also, in conjunction with the bind command, the "%q" field can be used in place of "%W" as the access command:
bind Button <Key-Return> {%q flash; %q invoke}
okay so while this behavior totally makes sense from the standpoint of encapsulation, it causes problems with existing Tcl/Tk applications. π a lot of existing apps are written with bindings that use "%W", and a lot of library procedures just assume the window name is the access command. awkward.
so this is where itcl::purist comes in β it controls a backward-compatibility mode:
- by default, this variable is
"0", and the window name can be used as an access command in any context. whenever theunknownprocedure stumbles across a widget name, it simply uses"winfo command"to figure out the appropriate command name. easy, forgiving, old-school. - if this variable is set to
"1", that backward-compatibility mode is disabled. this gives you better encapsulation, but heads up β using the window name as the access command may lead to"invalid command"errors. so like, you asked for strict mode, you got strict mode. π«Ά
itcl::versionβ when an interpreter is created,[incr Tcl]initializes this variable to hold the version number in the formx.y. changes toxrepresent major changes with probable incompatibilities, and changes toyrepresent small enhancements and bug fixes that retain backward compatibility. so if the first number moves, brace yourself. if the second one moves, you're fine. iykyk. π
π KEYWORDS π
itcl, variables
and that's the whole page, bestie!! π¦ no notes, she ate, we love a short manpage. this was the itclvars(n) page from itcl, version 3.0 β so if anyone asks, it's itcl 3.0 energy all the way down, periodt. πβ¨π
π¦ where this page comes from
- alpine 3.22: tcl-doc 8.6.16-r0 Β· TCL
- alpine 3.23: tcl-doc 8.6.17-r0 Β· TCL
- alpine 3.23: tcl9-doc 9.0.3-r0 Β· TCL
- alpine 3.24: tcl-doc 8.6.17-r1 Β· TCL
- alpine 3.24: tcl9-doc 9.0.3-r2 Β· TCL
- arch rolling: tcl 8.6.16-1 Β· TCL
- fedora 43: itcl 4.3.2-1.fc43 Β· TCL
- fedora 43: itcl 4.3.2-2.fc43 Β· TCL
- fedora 44: itcl 4.3.2-3.fc44 Β· TCL
- nixos 26.05: tcl 9.0.3
- nixpkgs unstable: incrtcl 4.2.3
- nixpkgs unstable: tcl 9.1.0
- opensuse-leap 16.0: tcl 8.6.15-160000.2.2 Β· TCL
- opensuse-leap 16.0: tcl 8.6.15-160000.2.2 Β· TCL
- opensuse-leap 16.0: tcl 8.6.15-160000.2.2 Β· TCL
- opensuse-leap 16.0: tcl 8.6.15-160000.2.2 Β· TCL
- Copyright (c) 1993-1998 Lucent Technologies, Inc
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms