tcl::chan::core(n)

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

πŸ’– tcl::chan::core(n) β€” Basic reflected/virtual channel support πŸ’–

okay bestie, so this is the manual for tcl::chan::core, living in the Reflected/virtual channel support corner of the tcllib universe. sit down, grab a boba, we're doing channel guts today 🧚✨


✨ NAME ✨

tcl::chan::core β€” basic reflected/virtual channel support. yes. that's the whole vibe. it's the foundation bestie, the base layer, the primer before the makeup πŸ’…


🌸 SYNOPSIS 🌸

package require Tcl 8.5 9

package require TclOO

package require tcl::chan::core ?1.1?

::tcl::chan::core objectName

objectName initialize thechannel mode

objectName finalize thechannel

objectName destroy

πŸ¦‹ DESCRIPTION πŸ¦‹

so the tcl::chan::core package hands you a TclOO class that implements all the common behaviour that virtually every reflected or virtual channel needs β€” we're talking initialization and finalization, the little rituals, the getting-ready-and-going-home of channel life πŸŽ€

and the way this class expects to be used? either as the superclass of a concrete channel class, or mixed into one. no cap, those are the two options. pick your fighter πŸ’…


πŸ‘‘ CLASS API πŸ‘‘

  • ::tcl::chan::core objectName β€” this makes a brand-new channel core object, and it comes with a global Tcl command attached whose name is objectName. you can use that command to poke at the object in all the ways listed down in the INSTANCE API section. it's giving "your new bestie has a name, use it" 🫢

⭐ INSTANCE API ⭐

okay so the API of channel core instances is tiny β€” literally just two methods β€” and both of them line up with channel handler commands (for the receipts, see TIP 219 at http:/tip.tcl.tk/219). and important: they expect to be called from whatever object instance the channel core got made a part of. iykyk 😌

  • objectName initialize thechannel mode β€” this method does the standard behaviour for the initialize method of channel handlers. using introspection it sniffs out the handler methods that the instance supports, and returns a list with their names β€” exactly the shape the Tcl core's reflected-channel support is expecting πŸ”₯

and plot twist: it also stashes the channel handle in an instance variable so sub-classes can reach it later. thoughtful queen behavior fr fr πŸ’œ

  • objectName finalize thechannel β€” this one does the standard behaviour for the finalize method of channel handlers. and what does it do? it simply destroys itself. dramatic exit, no notes, periodt πŸ’€
  • objectName destroy β€” destroying the channel core instance closes the channel it was initialized for (see the initialize method above, bestie, keep up πŸ’…). BUT β€” and this is the ✨important caveat✨ β€” when it's destroyed from inside a call of finalize, that closing does not happen, because we're assuming Tcl itself is the one destroying the channel. so like, don't double-destroy, that's not the move πŸ™ˆ

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

ngl, this document β€” and the package it describes β€” will undoubtedly contain bugs and other problems. it's giving "we know, we know." 😭

please report them in the category virtchannel of the Tcllib Trackers: http://core.tcl.tk/tcllib/reportlist

and please also send in any ideas for enhancements you have for either the package and/or the documentation. we want them, fr fr 🫢

if you're proposing code changes, please provide unified diffs β€” that's the output of diff -u, bestie, we need the format πŸ‘‘

also noting: attachments are strongly preferred over inlined patches. to attach something, go to the Edit form of the ticket right after you create it, then use the left-most button in the secondary navigation bar. there it is. that's the button. go get it 🌈


πŸŽ€ KEYWORDS πŸŽ€

reflected channel, tip 219, virtual channel


🌸 CATEGORY 🌸

Channels


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


and that's the whole page bestie!! this one shipped as part of tcllib, version 1.1 β€” so if you ever need to cite it, that's the source and the version right there. now go forth and build your reflected channels, you absolute icon πŸ‘‘βœ¨πŸ’…

πŸ“¦ where this page comes from