stooop(3tcl)
β¨ stooop β the Tcl manual page, but make it a group chat π
okay bestie, so this is stooop, aka the Simple Tcl Only Object Oriented Programming extension, and it lives in the 3tcl section of the manual. it's giving C++ but make it Tcl, and honestly? iconic. π
πΈ NAME πΈ
stooop β an object oriented extension, periodt. π
β¨ SYNOPSIS β¨
package require Tcl 8.5 9
package require stooop ?4.4.2?
::stooop::class name body
::stooop::new class ?arg arg ...?
::stooop::delete object ?object ...?
::stooop::virtual proc name {this ?arg arg ...?} ?body?
::stooop::classof object
::stooop::new object
::stooop::printObjects ?pattern?
::stooop::record
::stooop::report ?pattern?
π¦ DESCRIPTION π¦
So this package hands you a bunch of commands to extend Tcl in an object oriented way β with a syntax and behaviour that's familiar if you've ever touched C++. Stooop only drops in a few new commands: class, new, delete, virtual and classof. Throw in a couple of coding conventions and that is literally all you need to know to use stooop. fr fr, it's designed to be as simple as possible to use. π
ngl this manual is very succinct β it's meant as a quick lil reminder for the programmer, who at this point should have already read the thorough stooop_man.html HTML documentation. π
::stooop::class name body
This command creates a class. β¨ The body β similar in contents to a Tcl namespace (which a class actually also is, lowkey) β contains member procedure definitions. Member procedures can also be defined outside the class body, by prefixing their name with class::, exactly like you'd do with namespace procedures.
proc class {this ?arg arg ...?} ?base {?arg arg ...?} ...? bodyβ This is the constructor procedure for the class. It gets invoked following anewinvocation on the class. It must have the same name as the class and a first argument namedthis. Any number of base class specifications, including arguments to be passed to their constructor, are allowed before the actual body of the procedure. π«Άproc ~class {this} bodyβ This is the destructor procedure for the class. It gets invoked following adeleteinvocation. Its name must be the concatenation of a single~character followed by the class name (as in C++). It must have a single argument namedthis. πproc name {this ?arg arg ...?} bodyβ This is a member procedure of the class, since its first argument is namedthis. It allows simple access of member data for the object referenced bythisinside the procedure. For example:
set ($this,data) 0
proc name {?arg arg ...?} bodyβ This is a static (as in C++) member procedure of the class, since its first argument is not namedthis. Static (global) class data can be accessed as in:
set (data) 0
proc class {this copy} bodyβ This is the optional copy procedure for the class. It must have the same name as the class and exactly 2 arguments namedthisandcopy. It gets invoked following anewinvocation on an existing object of the class. π§
::stooop::new class ?arg arg ...?
This command is used to create an object. The first argument is the class name, and it's followed by the arguments needed by the corresponding class constructor. A unique identifier for the object you just created is returned. β
::stooop::delete object ?object ...?
This command is used to delete one or several objects. It takes one or more object identifiers as argument(s). bye bye bestie π
::stooop::virtual proc name {this ?arg arg ...?} ?body?
The virtual specifier may be used on member procedures to achieve dynamic binding. A procedure in a base class can then be redefined (overloaded) in the derived class(es). If the base class procedure is invoked on an object, it's actually the derived class procedure which gets invoked, if it exists. And if the base class procedure has no body, then it's considered to be a pure virtual and the derived class procedure is always invoked. main character energy, honestly. π
::stooop::classof object
This command returns the class of the existing object passed as a single parameter. it's giving "who's your mother" but make it polite πΈ
::stooop::new object
This command is used to create an object by copying an existing object. The copy constructor of the corresponding class is invoked if it exists β otherwise a simple copy of the copied object data members is performed. β¨
π DEBUGGING π
Environment variables
STOOOPCHECKDATAβ Setting this variable to any true value will cause stooop to check for invalid member or class data access. πSTOOOPCHECKPROCEDURESβ Setting this variable to any true value will cause stooop to check for invalid member procedure arguments and pure interface classes instanciation.STOOOPCHECKALLβ Setting this variable to any true value will cause stooop to activate both procedure and data member checking. the whole package, no crumbs. πSTOOOPCHECKOBJECTSβ Setting this variable to any true value will cause stooop to activate object checking. The following stooop namespace procedures then become available for debugging:printObjects,recordandreport.STOOOPTRACEPROCEDURESβ Setting this environment variable to eitherstdout,stderror a file name activates procedure tracing. The stooop library will then output to the specified channel 1 line of informational text for each member procedure invocation.STOOOPTRACEPROCEDURESFORMATβ Defines the trace procedures output format. Defaults to"class: %C, procedure: %p, object: %O, arguments: %a".STOOOPTRACEDATAβ Setting this environment variable to eitherstdout,stderror a file name activates data tracing. The stooop library will then output to the specified channel 1 line of informational text for each member data access.STOOOPTRACEDATAFORMATβ Defines the trace data output format. Defaults to"class: %C, procedure: %p, array: %A, object: %O, member: %m, operation: %o, value: %v".STOOOPTRACEDATAOPERATIONSβ When tracing data output, by default all read, write and unsetting accesses are reported, but the user can set this variable to any combination of the lettersr,w, andufor more specific tracing (please refer to thetraceTcl manual page for more information).STOOOPTRACEALLβ Setting this environment variable to eitherstdout,stderror a file name enables both procedure and data tracing. slay, everything on. π₯
::stooop::printObjects ?pattern?
Prints an ordered list of existing objects, in creation order, oldest first. Each output line contains the class name, object identifier and the procedure within which the creation occurred. The optional pattern argument (as in the Tcl string match command) can be used to limit the output to matching class names. π
::stooop::record
When invoked, a snapshot of all existing stooop objects is taken. Reporting can then be used at a later time to see which objects were created or deleted in the interval. πΈ
::stooop::report ?pattern?
Prints the created and deleted objects since the ::stooop::record procedure was invoked last. If present, the pattern argument limits the output to matching class names.
π EXAMPLES π
Please see the full HTML documentation in stooop_man.html. (yes bestie, go read it, it's the whole vibe) π
π¦ BUGS, IDEAS, FEEDBACK π¦
This document, and the package it describes, will undoubtedly contain bugs and other problems. π Please report such in the category stooop of the Tcllib Trackers [http://core.tcl.tk/tcllib/reportlist](http://core.tcl.tk/tcllib/reportlist). Please also report any ideas for enhancements you may have for either package and/or documentation.
When proposing code changes, please provide unified diffs, i.e the output of diff -u.
Note further that attachments are strongly preferred over inlined patches. Attachments can be made by going to the Edit form of the ticket immediately after its creation, and then using the left-most button in the secondary navigation bar.
β KEYWORDS β
C++, class, object, object oriented
π CATEGORY π
Programming tools
and that's the whole page, bestie π«Ά this was tcllib, version 4.4.2, and yeah it's the stooop(3tcl) page. go forth and write some classes, you got this π
π¦ where this page comes from
- debian trixie: tcllib 2.0+dfsg-4 Β· Tcl
- ubuntu questing: tcllib 2.0+dfsg-4
- ubuntu resolute: tcllib 2.0+dfsg-5 Β· Tcl
- ubuntu stonking: tcllib 2.0+dfsg-6 Β· Tcl
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms