is(n)
π¦ NAME π¦
itcl::is β bestie, this is the lil test that checks whether an argument is a class or an object. That's it, that's the whole job, and it does it flawlessly π
(it lives in the [incr Tcl] manual, under the name is(n) β yes the section letter is part of the name, we don't make the rules π)
β¨ SYNOPSIS β¨
itcl::is option ?arg arg ...?
π DESCRIPTION π
okay so here's the tea π β the is command checks whether the argument you hand it is a class or an object, and which one it checks for depends on the option you gave. If the argument is a class or an object, you get 1 back. If it's not, you get 0. No drama, no error, just a clean little boolean.
and ngl there's a bonus: the is command also recognizes the commands wrapped in the itcl code command π§ so those wrapped-up command names still get vibe-checked properly.
The option argument is what decides which action the command actually carries out. The legal options β and yes, they may be abbreviated, so you don't have to type the whole thing, queen π β are:
is classcommand β returns1if command is a class, and returns0otherwise. π
β οΈ heads up: you have to give the fully qualified name of the class as the command argument. So if a class lives in a namespace, the namespace has to be spelled out too. So if a classCresides in a namespaceN, you call it like this:
is N::C
or
is ::N::C
is object ?-class className?command β returns1if command is an object, and returns0otherwise. π¦
If you pass the optional -class parameter, then command gets checked within the context of the class you named. But bestie, listen: className has to exist. If it doesn't, you get an error, periodt. So if you're not 100% sure className is actually a class, you gotta check its existence beforehand yourself, or wrap the whole thing in a catch statement. no cap π
So if c is an object in the class C, in namespace N, then these are the possibilities (and all of them return 1):
set obj [N::C c]
itcl::is object N::c
itcl::is object c
itcl::is object $obj
itcl::is object [itcl::code c]
π KEYWORDS π
- class
- object
and that's the whole page, bestie!! π«Ά this one came from itcl, version 3.3, and it's the is(n) page β go forth and vibe check your classes and objects responsibly πβ¨
π¦ 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