Tcl_CallWhenDeleted(3)
π Tcl_CallWhenDeleted β bestie edition π
okay so this is the Tcl Library Procedures page for Tcl_CallWhenDeleted and Tcl_DontCallWhenDeleted, and honestly? it's giving "i want a lil heads-up before my interpreter β¨perishesβ¨". sit with me, this one's short and sweet. π
β¨ NAME β¨
Tcl_CallWhenDeleted, Tcl_DontCallWhenDeleted β arrange for a callback for when the interpreter is deleted π«Ά
πΈ SYNOPSIS πΈ
#include <tcl.h>
Tcl_CallWhenDeleted(interp, proc, clientData)
Tcl_DontCallWhenDeleted(interp, proc, clientData)
π¦ ARGUMENTS π¦
Tcl_Interp *interp(in) β the interpreter you're associating this callback with. it's her interpreter. πTcl_InterpDeleteProc *proc(in) β the procedure to call wheninterpgets deleted.void *clientData(in) β an arbitrary one-word value that gets passed toproc. one word. that's it. no more, no less. π
π DESCRIPTION π
Tcl_CallWhenDeleted arranges for proc to be called by Tcl_DeleteInterp if/when interp is deleted at some future time. if/when β like, not right now, but eventually, whenever that moment comes. β³
proc will be invoked just before the interpreter is deleted, but β and this is the important part, bestie β the interpreter will still be valid at the time of the call. so you're saying goodbye while she's still standing. π iconic behaviour.
proc should have arguments and result that match the type Tcl_InterpDeleteProc:
typedef void Tcl_InterpDeleteProc(
void *clientData,
Tcl_Interp *interp);
the clientData and interp parameters are copies of the clientData and interp arguments you gave to Tcl_CallWhenDeleted. typically, clientData points to an application-specific data structure that proc uses to perform cleanup when an interpreter is about to go away. the cleanup era. π§Ήβ¨
and proc does not return a value. it returns void. no notes, no receipts, no little gift back. π
Tcl_DontCallWhenDeleted cancels a previous call to Tcl_CallWhenDeleted with the same arguments, so that proc will not be called after all when interp is deleted. it's the "jk bestie, nevermind" of functions. π
if there is no deletion callback that matches interp, proc, and clientData, then the call to Tcl_DontCallWhenDeleted has no effect. like, literally nothing happens. vibe check: failed, but gently. π«Ά
β οΈ heads up bestie β οΈ note that if the callback is being used to delete a resource that must be released on exit, Tcl_CreateExitHandler should be used to ensure that a callback is received even if the application terminates without deleting the interpreter. do NOT skip this. the interpreter might dip without warning and your cleanup would be left on read. π
π SEE ALSO π
π KEYWORDS π
callback, cleanup, delete, interpreter
and that's the whole page, bestie, no cap. this one's from the Tcl 7.0 era β yes, 7.0, she's vintage, she's a classic, she ate and left no crumbs. π β¨ mwah, go clean up your interpreters responsibly. π¦πΈ
π¦ where this page comes from
- alpine 3.23: tcl9-doc 9.0.3-r0 Β· TCL
- alpine 3.24: tcl9-doc 9.0.3-r2 Β· TCL
- fedora 43: tcl-doc 1:9.0.2-1.fc43 Β· TCL AND GPL-3.0-or-later WITH Bison-exception-2.2 AND BSD-3-Clause
- fedora 44: tcl-doc 1:9.0.2-1.fc44 Β· TCL AND GPL-3.0-or-later WITH Bison-exception-2.2 AND BSD-3-Clause
- nixos 26.05: tcl 9.0.3
- nixpkgs unstable: tcl 9.1.0
- Copyright (c) 1993 The Regents of the University of California
- Copyright (c) 1994-1996 Sun Microsystems, Inc
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms