Tcl-hack(3)
π Tcl-hack(3) β internal details, bestie
okay so this is Tcl-hack(3) from the User Contributed Perl Documentation, and the whole vibe is literally βsome internal details/discussions; ordinary user should not bother about this.β π So if you're just here to use the module, bestie, you can skedaddle β this page is for the internal lore. β¨
π§Ή Command table cleanup
In V1.03 command table cleanup was introduced. This tries to keep the internal structure and command table clean. π«§ In V1.02 and prior heavy use of sub { .. } in Tcl commands could pollute these tables as they were never cleared. Command table cleanup tries to alleviate this. π
if you call create_tcl_sub the internal reference exists until you delete_ref or _code_dispose it, or you call create_tcl_sub with the same DESCRNAME.
if the internal reference was created internally by call(...) there are two rules:
- If the command is an
afterthe internal references are kept at least until 1 second after the delay. If there are still other users of theTCLNAMEthen it is not deleted until the last one goes away. If another call with the sameCODEREFhappens before this, then it will get registered as a user without any need to delete/recreate the tcl command first. π - otherwise a
DESCRNAMEis created with the text sections of the command, prefaced by=. Like=after 1000or=:.m.m add command -command -label Exitor=::button .f3.b8 -text conn -commandor=gets sock9ac2b50or=fileevent sock9827430 writable.
the TCLCODES created for that command will be kept at least until a command with the same DESCRNAME and containing a subroutine reference is run again. Since many DESCRNAMES can reference the same TCLNAME, only when the last DESCRNAME referencing a TCLNAME is released is the TCLNAME purged. π
NOTE: Since$interp->call('fileevent','sock9827430','writable');does not contain a subroutine reference, it will not release/free theTCLNAME/DESCRNAMEcreated by$interp->call('fileevent','sock9827430','writable',sub{...});even though that is the way you deactivate a writable/readable callback in Tcl. π
Prior to V1.06 there was also a problem with the coderef never getting cleared from sas, a refcount was kept at the PVCV that prevented it from getting garbage collected, but that SV itself got lost and could never be garbage collected, thereby also keeping anything in that codes PAD. π
To assist in tracking changes to the internal table and the commands table 3 trace subs were added, set them to non-blank or non-zero to add the tracking output to SYSOUT, like this in your code:
sub Tcl::TRACE_SHOWCODE(){1}
Tcl::TRACE_SHOWCODEβ Display all generated Tcl code bycall(). Be aware:Tkx::MainLoopruns by issuing a lot ofwinfo exists .calls, a LOT. But this is a nice way to tell what your programs are doing to Tcl. πTcl::TRACE_CREATECOMMANDβ Display Tcl subroutine creation bycall/create_tcl_subπ οΈTcl::TRACE_DELETECOMMANDβ Display Tcl subroutine deletion bycleanup/delete_ref/_code_disposeπ§½
π§ Moving Tcl/Tk around with Tcl.pm
NOTE: explanations below is for developers managing Tcl/Tk installations itself, users should skip this section. π
In order to create Tcl/Tk application with this module, you need to make sure that Tcl/Tk is available within visibility of this module. There are many ways to achieve this, varying on ease of starting things up and providing flexible movable archived files. π
Following list enumerates them, in order of increased possibility to change location. β
- First method β Install Tcl/Tk first, then install Perl module Tcl, so installed Tcl/Tk will be used. This is most normal approach, and no care of Tcl/Tk distribution is taken on Perl side (this is done on Tcl/Tk side). πΈ
- Second method β Copy installed Tcl/Tk binaries to some location, then install Perl module Tcl with a special action to make
Tcl.pmknow of this location. This approach makes sure that only chosen Tcl installation is used. π¦ - Third method β During compiling Tcl Perl module, Tcl/Tk could be statically linked into module's shared library and all other files zipped into a single archive, so each file extracted when needed. π
To link Tcl/Tk binaries, prepare their libraries and then instruct Makefile.PL to use these libraries in a link stage. (TODO provide better detailed description) π§
okay bye bestie π β this was Tcl-hack(3) from perl v5.42.2, dated 2026-02-15. slay. β¨
π¦ where this page comes from
- alpine 3.24: perl-tcl-doc 1.53-r2 Β· GPL-1.0-or-later OR Artistic-1.0-Perl
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms