Tcl_Init(3tcl)

πŸ“¦
version 9.0.4 Β· 2 versions
, in debian trixie, ubuntu questing, ubuntu resolute, ubuntu stonking

πŸ’– NAME πŸ’–

Tcl_Init β€” find and source that initialization script, bestie πŸ”βœ¨


🌸 SYNOPSIS 🌸

#include <tcl.h>

int
Tcl_Init(interp)

const char *
Tcl_SetPreInitScript(scriptPtr)

πŸŽ€ ARGUMENTS πŸŽ€

  • Tcl_Interp *interp (in) β€” the interpreter we're initializing, periodt.
  • const char *scriptPtr (in) β€” the address of the initialization script. Yes, the actual address. Give it here. 🫢

✨ DESCRIPTION ✨

Tcl_Init is your lil helper procedure that goes and finds the init.tcl script, then sources it. That script should be living somewhere on the Tcl library path β€” that's the vibe check it's doing. 🌈

Like, usually you'd call Tcl_Init from inside your Tcl_AppInit procedures. That's the moment. That's the main character energy. πŸ‘‘

Now, Tcl_SetPreInitScript is the fun one. It registers the pre-initialization script and hands you back the former script pointer β€” the one that just got replaced. So you're not just setting, you're swapping. πŸ’…

A value of NULL may be passed to not register any script. So if you wanna clear it out, NULL is your girl. 🚫

The pre-initialization script gets executed by Tcl_Init before accessing the file system. Why do we care? Because the whole purpose is to typically prepare a custom file system (think: an embedded zip-file, iconic) so it can be activated before the search happens. Setup first, search second. No cap. πŸ—‚οΈβœ¨

And here's the important bit for the stub-enabled embedders out there β€” listen up, this one's a real caveat πŸ‘‡

When you're working with stub-enabled embedders, the stubs table has to be initialized first, using one of these:

  • Tcl_InitSubsystems
  • Tcl_SetPanicProc
  • Tcl_FindExecutable
  • TclZipfs_AppHook

...and only then may Tcl_SetPreInitScript be called. Order matters, bestie. Do it out of order and it's giving chaos. 😭


πŸ¦‹ SEE ALSO πŸ¦‹

  • Tcl_AppInit
  • Tcl_Main

πŸ’œ KEYWORDS πŸ’œ

application, initialization, interpreter


okay that's the whole page, you ate it, you understood it, I'm so proud of you fr fr πŸ₯ΉπŸ«Ά

this was brought to you by Tcl 9.0, and the page itself is Tcl_Init(3tcl) β€” mwah, go write something slay πŸ’–βœ¨

πŸ“¦ where this page comes from