Tcl_PkgRequire(3)
β¨ Tcl_PkgRequire β package version control, but make it a vibe β¨
okay bestie, so this is a page from the Tcl Library Procedures manual, and it's all about the C-level functions that let you do package stuff. The whole girlboss squad is here: Tcl_PkgRequire, Tcl_PkgRequireEx, Tcl_PkgRequireProc, Tcl_PkgPresent, Tcl_PkgPresentEx, Tcl_PkgProvide, and Tcl_PkgProvideEx. Seven icons. One page. Let's go π
π SYNOPSIS π
like, here's how you call them, no cap:
#include <tcl.h>
const char *
Tcl_PkgRequire(interp, name, version, exact)
const char *
Tcl_PkgRequireEx(interp, name, version, exact, clientDataPtr)
int
Tcl_PkgRequireProc(interp, name, objc, objv, clientDataPtr)
const char *
Tcl_PkgPresent(interp, name, version, exact)
const char *
Tcl_PkgPresentEx(interp, name, version, exact, clientDataPtr)
int
Tcl_PkgProvide(interp, name, version)
int
Tcl_PkgProvideEx(interp, name, version, clientData)
π«Ά ARGUMENTS π«Ά
Tcl_Interp *interp(in) β the interpreter where the package is needed or available. it's giving home base πconst char *name(in) β the package's name. yeah, just the name.const char *version(in) β a version specification string, exactly the kind described forpackage require. so like, it knows what you mean.int exact(in) β non-zero means ONLY that one specific version fromversionis acceptable, periodt. zero means newer versions are also fine, as long as they have the same major version number asversion. lowkey flexible β¨const void *clientData(in) β an arbitrary value you want associated with the package. anything. no judgement πvoid *clientDataPtr(out) β a pointer to a place where the value associated with the matching package gets stored. it is only changed if the pointer is notNULLand the function completed successfully. the storage can be any pointer type with the same size as avoidpointer.Tcl_Size objc(in) β the number of requirements. like how many asks you're making.Tcl_Obj* objv[](in) β an array of requirements. the whole list, bestie.
π DESCRIPTION π
so these procedures are the C-level interfaces to Tcl's package and version management facilities. C-level besties for the Tcl-level slay.
Tcl_PkgRequireis equivalent to thepackage requirecommand.Tcl_PkgPresentis equivalent to thepackage presentcommand.Tcl_PkgProvideis equivalent to thepackage providecommand.
for the deets on what these actually do, go read the docs for the Tcl commands. they spill the tea there π
if Tcl_PkgPresent or Tcl_PkgRequire complete successfully, they return a pointer to the version string for the version of the package that is provided in the interpreter β and heads up, that version may be different than version π. if an error happens, they return NULL and leave an error message sitting in the interpreter's result.
Tcl_PkgProvide returns TCL_OK when it completes successfully. if an error occurs it returns TCL_ERROR and leaves an error message in the interpreter's result. no in-between, we don't do that here.
Tcl_PkgProvideEx, Tcl_PkgPresentEx, and Tcl_PkgRequireEx let you set and retrieve the client data associated with the package. in all other respects they are equivalent to the matching functions. same energy, extra feature π
Tcl_PkgRequireProc is the form of package require that handles multiple requirements. the other forms are there for backward compatibility and translate their invocations to this form. so it's kind of the main character and the others are just doing their little translations π«‘
π₯ REFERENCE COUNT MANAGEMENT π₯
okay this is the part where you pay attention because it's a real caveat:
The requirement values given (in theobjvargument) toTcl_PkgRequireProcmust have non-zero reference counts. non-zero. periodt.
π KEYWORDS π
package, present, provide, require, version
πΈ SEE ALSO πΈ
and that's the whole page, bestie!! this was Tcl 7.5, dated... well, that's the version and date footer energy right there, and the manual page signs off as Tcl_PkgRequire(3) π go forth and require your packages 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
- Copyright (c) 1996 Sun Microsystems, Inc
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms