tcl::chan::variable(n)

πŸ“¦
version 2.0 Β· 2 versions
, in fedora 43, fedora 44, nixos 26.05, nixpkgs unstable

πŸ’– tcl::chan::variable(n) β€” bestie edition πŸ’–

okay so this is a page from the tcllib docs, living under the Reflected/virtual channel support umbrella. yes it's a manual page, yes it's n section, and yes we're gonna make it cute. pull up a chair 🫢


✨ NAME ✨

tcl::chan::variable β€” an in-memory channel that uses a variable for storage. that's the whole vibe. channel but the data lives in a variable. slay.


🌸 SYNOPSIS 🌸

package require Tcl 8.5 9

package require TclOO

package require tcl::chan::events ?1.1?

package require tcl::chan::variable ?1.0.5?

::tcl::chan::variable varname

the ?1.1? and ?1.0.5? are minimum-version hints btw β€” that's just how these package require lines roll. not me being mysterious on purpose πŸ’…


πŸ¦‹ DESCRIPTION πŸ¦‹

so the tcl::chan::variable package gives you a command that makes channels which live purely in memory. they're random-access, which is the fancy way of saying they're seekable β€” you can jump around in them like it's nothing. main character energy fr.

here's the lil twist though, and it's the whole point of this package: unlike the channels you get from tcl::chan::memchan, the data is not hidden inside the channel. instead it's stored in an associated variable, and you name that variable at construction time. so you can literally just... look at your data. it's right there. iconic.

related packages if you wanna go down the rabbit hole: tcl::chan::memchan and tcl::chan::string. ✨

also, for the people who care about internals (iykyk): the internal TclOO class that implements the channel handler is a sub-class of the tcl::chan::events framework. so it's events-flavored underneath. πŸŽ€


πŸŽ€ API πŸŽ€

  • ::tcl::chan::variable varname β€” this command creates a brand new variable channel and hands you back its handle. the content of the channel is stored in the associated namespace variable varname. that's it. that's the whole API. one command, maximum slay. πŸ‘‘

πŸ’€ BUGS, IDEAS, FEEDBACK πŸ’€

ngl, this document and the package it describes will undoubtedly contain bugs and other problems. that's just how software is, bestie. so please report them in the category virtchannel of the Tcllib Trackers at [http://core.tcl.tk/tcllib/reportlist]. also β€” if you have ideas for enhancements for either the package and/or the documentation, send those too. we want them. 🫢

when you're proposing code changes, please provide unified diffs, i.e. the output of diff -u. no freestyle diffs please.

also note: attachments are strongly preferred over inlined patches. to attach something, go to the Edit form of the ticket immediately after its creation, and then use the left-most button in the secondary navigation bar. that's the secret handshake. 🧚


⭐ KEYWORDS ⭐

in-memory channel, reflected channel, tip 219, virtual channel


🌈 CATEGORY 🌈

Channels


Copyright (c) 2009 Andreas Kupries <andreas_kupries@users.sourceforge.net>


and that's the whole page!! πŸ’– this one shipped as part of tcllib, version 1.0.5, and it's the tcl::chan::variable(n) page β€” so if you cite it, cite it right. periodt. πŸ’…βœ¨

πŸ“¦ where this page comes from