tcl::t...counter(3tcl)
โจ tcl::transform::counter โ the counter transformation, bestie edition โจ
okay so this is a page from the 3tcl manual, sitting in the Reflected/virtual channel support corner of the world ๐ and it's about counting bytes. no cap, that's the whole vibe.
๐ธ NAME ๐ธ
tcl::transform::counter โ the Counter transformation. that's it, that's the name, she's simple and she's iconic ๐
๐ SYNOPSIS ๐
package require Tcl 8.6 9
package require tcl::transform::core ?1.1?
package require tcl::transform::counter ?1.1?
::tcl::transform::counter chan -option value...
๐ DESCRIPTION ๐
so the tcl::transform::counterr package (yes, two r's, that's literally what it says, do not come for me ๐) gives you a command that builds a channel transformation. and what does this transformation do?? it passes the read bytes and the written bytes straight through, completely unchanged โ exactly like tcl::transform::identity does โ but bestie. it also counts the bytes it has seen, separately for each direction ๐งฎโจ and then it stashes those counts in Tcl variables that you name at construction time. it's giving "i'm just standing here" but it's actually keeping receipts.
the related transformations in this module โ go look at them, they're the friend group ๐ซถ โ are tcl::transform::adler32, tcl::transform::crc32, tcl::transform::identity, and tcl::transform::observe.
and the internal TclOO class that actually implements the transform handler? it's a subclass of the tcl::transform::core framework. family tree matters, periodt ๐ณ
๐ฅ API ๐ฅ
::tcl::transform::counter chan -option value...โ this command spins up a counter transformation on top of the channel chan and hands you back its handle. and the options it accepts are... ๐-read-variablevarname โ the value here is the name of a global or namespaced variable, i.e. the spot where the transformation has to store the byte count of the data that was read from the channel. ๐
and if you don't specify it, or you give it the empty string, then the read-direction counter just... isn't saved. no variable, no vibes. ๐ซฅ
-write-variablevarname โ same deal, other direction: the value is the name of a global or namespaced variable, the place where the transformation has to store the byte count of the data written to the channel. โ๏ธ
and again, if it's not specified or it's the empty string, the write-direction counter is not saved. ๐ซฅ
๐ญ BUGS, IDEAS, FEEDBACK ๐ญ
ngl, this document and the package it describes will undoubtedly contain bugs and other problems. like, undoubtedly. it's said right there. ๐ please report them in the virtchannel category of the Tcllib Trackers: http://core.tcl.tk/tcllib/reportlist. and while you're at it, please also drop any ideas for enhancements you have for either the package and/or the documentation โ we want them, fr fr ๐ซถ
when you're proposing code changes, please provide unified diffs, i.e. the output of diff -u. that's the move. ๐ง
also note: attachments are strongly preferred over inlined patches. you make an attachment 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. left-most button. that one. ๐โจ
๐ฆ KEYWORDS ๐ฆ
channel transformation, counter, reflected channel, tip 230, transformation, virtual channel
๐ CATEGORY ๐
Channels
๐ COPYRIGHT ๐
Copyright (c) 2009 Andreas Kupries <andreas_kupries@users.sourceforge.net>
okay that's the whole page!! ๐ and for the cute sign-off: this lil masterpiece comes to you from tcllib, version 1.1, and it lives under the tcl::t...counter(3tcl) title in the manual. mwah, go count some bytes, bestie ๐
๐โจ
๐ฆ 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
- Copyright (c) 2009 Andreas Kupries <andreas_kupries@users\&.sourceforge\&.net>
- ๐ girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms