Tcl_CallWhenDeleted(3)

πŸ“¦
version 9.0.3 Β· 3 versions
, in alpine 3.23, alpine 3.24, fedora 43, fedora 44, nixos 26.05, nixpkgs unstable

πŸ’– 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 when interp gets deleted.
  • void *clientData (in) β€” an arbitrary one-word value that gets passed to proc. 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